Skip to content

Python Examples

A pre-requisite for exchanging requests with the various Tasking API endpoints is to have a valid authentication token and contract_id, see Authentication API. In the examples below, the headers in the requests have placeholders for token and contract_id.

import requests
import json

# 0. Complete the following section with your contract_id and access token
#contract_id = ""
#ACCESS_TOKEN = ""


# 1. Get tasks list

ALEPH_API_URL = "https://api.satellogic.com"
tasks_uri = "/tasking/tasks/"

response = requests.get(
    f"{ALEPH_API_URL}{tasks_uri}", 
    headers={
        'AuthorizationToken': f'Bearer {ACCESS_TOKEN}',
        'X-Satellogic-Contract-Id': contract_id,
    },
)

# Raise an error if the request failed
response.raise_for_status()

# Print the JSON response
tasks = response.json()
print("Your tasks are: ")
print(json.dumps(tasks, indent=4))


# 2. Submit new task

# Task parameters
task_data = {
    "task_name": "Disney Land",
    "project_name": "Theme parks",
    "product": 169,
    "target": {
        "type": "Point",
        "coordinates": [
            72.905273,
            19.023001
        ]
    },
    "start": "2025-06-12T00:00:00",
    "end": "2025-06-23T00:00:00"
}

response = requests.post(
    f"{ALEPH_API_URL}{tasks_uri}",
    headers={
        'AuthorizationToken': f'Bearer {ACCESS_TOKEN}',
        'X-Satellogic-Contract-Id': contract_id,
        'Content-Type': 'application/json'
    },
    json=task_data
)

# Raise an error if the request failed
response.raise_for_status()

# Print the JSON response
response_data = response.json()
print("Task creation response: ")
print(json.dumps(response_data, indent=4))


# 3. Get task status

task_id = 299035

response = requests.get(
    f"{ALEPH_API_URL}{tasks_uri}{task_id}", 
    headers={
        'AuthorizationToken': f'Bearer {ACCESS_TOKEN}',
        'X-Satellogic-Contract-Id': contract_id,
    },
)

# Raise an error if the request failed
response.raise_for_status()

# Print the JSON response
task_status = response.json()
print("Task status response: ")
print(json.dumps(task_status, indent=4, sort_keys=True))


# 4. Get task captures

captures_uri = "/captures/"

response = requests.get(
    f"{ALEPH_API_URL}{tasks_uri}{task_id}{captures_uri}", 
    headers={
        'AuthorizationToken': f'Bearer {ACCESS_TOKEN}',
        'X-Satellogic-Contract-Id': contract_id,
    },
)

# Raise an error if the request failed
response.raise_for_status()

# Print the JSON response
captures = response.json()
print("Task captures response: ")
print(json.dumps(captures, indent=4, sort_keys=True))


# 5. Cancel task

task_id = 299029
cancel_uri = "/cancel/"

response = requests.patch(
    f"{ALEPH_API_URL}{tasks_uri}{task_id}{cancel_uri}", 
    headers={
        'AuthorizationToken': f'Bearer {ACCESS_TOKEN}',
        'X-Satellogic-Contract-Id': contract_id,
    },
)

# Raise an error if the request failed
response.raise_for_status()

# Print the JSON response
cancellation_response = response.json()
print("Task cancellation response: ")
print(json.dumps(cancellation_response, indent=4, sort_keys=True))