# IOTA Hub HTTP API guide

Use the HTTP API to submit observations and retrieve events, observations and
files. The [API reference](/developers/reference) lists every endpoint,
parameter and error code.

## Connect

Send your [API key](/developers/keys) in the `X-API-Key` header. Access depends
on your account permissions and the permissions selected for the key.
Use keys in scripts and server applications. Do not embed them in browser code.
An application that already holds a user's OccultWatcher API key can instead
obtain a Hub key on the user's behalf with the key-exchange operations in the
[API reference](/developers/reference).

The examples below use curl in a Bash-compatible shell, with the
[Python library](/developers/library) and [CLI](/developers/cli) equivalents in
their own tabs. Set the API address and load your key from a secure source:

```bash tab="curl"
export IOTA_HUB_API="https://api.iota-hub.com/public/v1"
```

```python tab="Python"
import os
from iota_hub import Client

with Client(api_key=os.environ["IOTA_HUB_API_KEY"]) as client:
    ...  # The Python examples below use this client.
```

```bash tab="CLI"
iota-hub auth login   # Paste your key at the hidden prompt
```

This is the production address. A test deployment shows its own base URL on
its [developers page](/developers). The curl commands assume your key is
available as `IOTA_HUB_KEY`.

## Submit an observation

Submission has four steps: create a draft, upload its files, finalize the
uploads, then wait for checks and submit. Each file needs a separate upload.

The library and the CLI run all four steps in one call:

```python tab="Python"
result = client.submit_folder("path/to/observation")
```

```bash tab="CLI"
iota-hub submit path/to/observation
```

Before repeating a submission, [check for an existing observation](#check-for-an-existing-observation).
For requests that support `Idempotency-Key`, use a unique key for each operation
and reuse it if you retry that operation. This prevents a retry from creating
another draft or repeating a completed action.

A repeated key returns the first call's stored response for 24 hours, whatever
the new request body contains, and without checking whether the resource still
exists. For example, reusing a create key after deleting that draft returns the
deleted draft's ID. Never reuse a key for a different request.

### 1. Create a draft

Send `POST /observations/drafts` with a list of files. The `slot` field identifies
the file's purpose:

| `slot`            | File                                        | Required       |
| ----------------- | ------------------------------------------- | -------------- |
| `report`          | NA report spreadsheet or Tangra JSON report | Yes            |
| `lightcurve`      | Light curve CSV                             | For POS/UNSURE |
| `log`             | Analysis log                                | For POS/UNSURE |
| `vizier`          | VizieR data                                 | No             |
| `aperture_record` | PyMovie `.pymovie` or Tangra `.lc` file     | No             |
| `attachment`      | Additional files, such as plots or notes    | No             |

Light curves and logs are optional for negative (NEG) observations. For
POS/UNSURE observations processed with other software, you can waive these
requirements after creating the draft by setting `bypass_required_files` with
[`PATCH /observations/{id}`](#update-draft-details); the create request does
not accept it. The draft's `readiness.missing_required` lists what is still
needed.

Set `size` to the file's byte count. You can also supply `sha256`, a
base64-encoded SHA-256 checksum, to verify that the uploaded file matches.
The Hub reads the observation details from the report.

```bash
curl -sS -X POST "$IOTA_HUB_API/observations/drafts" \
  -H "X-API-Key: $IOTA_HUB_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $CREATE_KEY" \
  -d '{"files": [
        {"slot": "report", "filename": "report.xlsx", "size": 51234},
        {"slot": "lightcurve", "filename": "lightcurve.csv", "size": 918273},
        {"slot": "log", "filename": "camera-log.txt", "size": 4096}
      ]}'
```

Replace the filenames and sizes with your own. Set `CREATE_KEY` to a unique
request identifier before running the command, and save it for retries.

The `201` response contains `observation` and `uploads`:

```json
{
  "observation": {
    "observation_id": "3f2b8c1e-6d4a-4f9b-a7e2-91c0d5b84e17",
    "status": "draft",
    "version": 2,
    "readiness": {
      "state": "in_progress",
      "missing_required": ["report", "..."]
    },
    "next_actions": ["upload:report"]
  },
  "uploads": [
    {
      "slot": "report",
      "filename": "report.xlsx",
      "upload_url": "https://s3.us-west-2.amazonaws.com/iota-hub-storage",
      "fields": {
        "key": "staging/3f2b8c1e-6d4a-4f9b-a7e2-91c0d5b84e17/report_upload_1773562200.418265_4f1a9c2e.xlsx",
        "policy": "...",
        "...": "..."
      },
      "file_key": "staging/3f2b8c1e-6d4a-4f9b-a7e2-91c0d5b84e17/report_upload_1773562200.418265_4f1a9c2e.xlsx",
      "attachment_id": null
    }
  ]
}
```

Save `observation.observation_id` as `ID` for subsequent requests (`obs_id` in
the Python examples). Each entry in
`uploads` contains:

| Field              | Purpose                                                   |
| ------------------ | --------------------------------------------------------- |
| `upload_url`       | Address to upload the file to                             |
| `fields`           | Form fields to send with the file                         |
| `file_key`         | Identifier used when finalizing an individual file upload |
| `slot`, `filename` | The file this upload is for                               |
| `attachment_id`    | Attachment identifier, or `null` for other files          |

### 2. Upload each file

Send each file directly to its `upload_url` using a multipart form POST.
Include every name and value from `fields` unchanged, then the file as the
last form part, named `file`. With curl, each form field uses `-F`, and the
file uses `-F "file=@path/to/file"`.

```bash
curl -sS -X POST "$UPLOAD_URL" \
  -F "key=staging/3f2b8c1e-6d4a-4f9b-a7e2-91c0d5b84e17/report_upload_1773562200.418265_4f1a9c2e.xlsx" \
  -F "policy=..." \
  -F "signature=..." \
  -F "file=@report.xlsx"
```

This example is shortened. Send every field returned in `fields`.

Do not send your API key to the upload URL. The returned form fields authorize
the upload. A successful upload returns `204`.

### 3. Finalize the uploads

Call `POST /observations/{id}/finalize` without a request body:

```bash
curl -sS -X POST "$IOTA_HUB_API/observations/$ID/finalize" \
  -H "X-API-Key: $IOTA_HUB_KEY" \
  -H "Idempotency-Key: $FINALIZE_KEY"
```

Use a new request identifier for `FINALIZE_KEY`, and reuse it for retries.
The Hub verifies the uploads, reads the report and starts the observer checks.
If a file is missing, the API returns `409 upload_missing`. Upload that file
and retry finalization.

```json
{
  "observation_id": "3f2b8c1e-6d4a-4f9b-a7e2-91c0d5b84e17",
  "status": "draft",
  "version": 6,
  "metadata": {
    "asteroid_id": "1036",
    "asteroid_name": "Ganymed",
    "star_catalog": "GAIA",
    "star_id": "1234567890123456789",
    "observed_at_utc": "2026-03-14T04:12:07Z",
    "result_type": "POS",
    "station": null
  },
  "readiness": { "state": "checking" },
  "checks": {
    "run_id": "5c9d2e7a-1b84-4f06-8a3c-e2f19b6d4a70",
    "status": "running",
    "findings": []
  },
  "next_actions": ["poll"],
  "report_parse": { "status": "parsed" }
}
```

The response includes `report_parse.status`: `parsed` if the report was read
successfully, or `failed` if it could not be read. Missing information is listed
in `readiness.missing_required`. Each station must be submitted as a separate
observation.

### 4. Wait for checks and submit

Request `GET /observations/{id}` periodically while checks run. The response
includes:

| Field                      | Meaning                                                    |
| -------------------------- | ---------------------------------------------------------- |
| `checks.status`            | `pending`, `running`, `complete` or `error`                |
| `readiness.checks_current` | Whether the checks reflect the draft's current contents    |
| `checks.findings`          | Problems found, with explanations and suggested fixes      |
| `checks.skipped`           | Checks that could not run; these do not prevent submission |
| `next_actions`             | Actions needed to finish the draft                         |

When `next_actions` includes `submit`, call:

```bash tab="curl"
curl -sS -X POST "$IOTA_HUB_API/observations/$ID/submit" \
  -H "X-API-Key: $IOTA_HUB_KEY" \
  -H "Idempotency-Key: $SUBMIT_KEY"
```

```python tab="Python"
observation = client.wait_for_checks(obs_id)
client.submit_draft(obs_id, version=observation.version)
```

```bash tab="CLI"
iota-hub drafts submit $ID
```

Use a new identifier for `SUBMIT_KEY`. The `200` response contains the submitted
observation and its `web_url`. Repeating this request for an already submitted
observation returns its current state.

To have the Hub submit automatically when the draft is ready, include
`"auto_submit_when_clean": true` when creating the draft. In the normal case the
Hub submits it once a check run completes clean, so a client may simply poll the
observation. While a submit is under way, `readiness.submit_in_progress` is `true`
and `next_actions` is `["poll"]`.

The draft can stay a draft, though: the automatic submit is attempted only when a
check run completes clean, and nothing retries it if that submit fails, the run
fails, the account is not active, or the draft is not ready at that moment. So
follow `next_actions` while polling: on `poll`, request the observation again; on
`submit`, call submit yourself. Stop with an error after your own timeout.

A submit call made while another submit of the same draft is running, such as the
automatic one, waits up to about 20 seconds for it and returns `200` with the
submitted observation. If that submit is still running after the wait, the API
returns `409 submit_in_progress`. This is not a failure by itself: request the
observation. If it is submitted, you are done; if it is a draft again with
`submit` in `next_actions`, call submit again.

A Tangra JSON report whose `optionalData.generator.application` is `Tangra` was
already checked in Tangra, and the warnings the observer confirmed there are kept
in `report_details.acknowledged_messages`. For such a report only the
required-files check runs; every other check is in `checks.skipped` with the
reason `Checked in Tangra before submission.` Once the required files are
present the draft is ready, and `auto_submit_when_clean` submits it.

A Tangra JSON report's two comments are kept apart. `reportData.comments`, the
comment archived with the observation, is returned as
`report_details.archive_comment`. The note for the reviewer,
`optionalData.submission.reviewerComments`, becomes the observation's `comments`
when the report is uploaded, unless the observation already has a comment: a
comment sent with `PATCH` is never replaced by the report. A note longer than
4000 characters is shortened to 4000.

The rest of a Tangra JSON report is returned in `report_details` as well:
`observers_more_than_listed`, `camera_model_for_delays`, `timing_detail`
(instrumental delays and time base), `light_curve`, `recording`, `prediction`,
`submission` (region and station number) and `double_stars` (Tangra's
double-star analysis, one entry per pair of events). Each is null when the report
has no value for it. Tokens such as `AppliedByTangra` are returned as written;
accept tokens you do not know. `prediction.owc_event_id` is shown as the report
wrote it, and the event it names becomes the observation's OWC link (see
below). The station position announced in OccultWatcher
(`station_latitude`, `station_longitude`, `station_altitude`) is in
`report_site`, which is personal data: null unless you own the observation or
may view personal data.

## Fix a draft

Follow `next_actions` to determine what the draft needs:

| Action                         | What to do                                                                |
| ------------------------------ | ------------------------------------------------------------------------- |
| `upload:<slot>`                | Upload the required file.                                                 |
| `confirm_asteroid_id`          | Confirm that the asteroid identifier is intentional.                      |
| `resolve_event_files_conflict` | Open the draft's `web_url` to resolve conflicting event files.            |
| `poll`                         | Checks or a submit are running. Wait, then request the observation again. |
| `run_checks`                   | Call `POST /observations/{id}/validation/runs`.                           |
| `dismiss_or_fix`               | Correct the reported problems or dismiss acceptable findings with a note. |
| `submit`                       | Submit the draft.                                                         |

Ignore unrecognized actions. New actions may be added in future versions.

A finding's `message` explains the problem, and `how_to_fix` suggests a
correction. Its `fingerprint` identifies it when making a dismissal request.
`doc_url` links to the check on the [observer checks page](/developers/checks).
`severity` is `warning` or `fail`. Any open finding, a warning included,
prevents submission (`409 open_findings`) until you fix or dismiss it.

```json
{
  "check_number": 12,
  "code": "observation_predicted_time",
  "name": "Near predicted time",
  "severity": "warning",
  "message": "Mid-event 04:12:07.40 · OWC at your station 04:11:31.25 · 36 s apart.",
  "how_to_fix": "The mid-event time is far from the predicted time. Check the recording's time source and the event you are reporting; if the timing is correct, dismiss with a note.",
  "doc_url": "https://iota-hub.com/developers/checks#check-12",
  "fingerprint": "9c1e4b7a02d35f68",
  "evidence": [
    {
      "field": "predicted_time",
      "expected": "04:11:31.25",
      "actual": "04:12:07.40",
      "expected_label": "Predicted",
      "actual_label": "Mid-event"
    }
  ]
}
```

### Replace a file

Request an upload URL for the replacement. The library and CLI also upload
and finalize the file in the same call:

```bash tab="curl"
curl -sS -X POST "$IOTA_HUB_API/observations/$ID/files/lightcurve/upload/init" \
  -H "X-API-Key: $IOTA_HUB_KEY" -H "Content-Type: application/json" \
  -d '{"filename": "lightcurve.csv"}'
```

```python tab="Python"
client.replace_file(obs_id, "lightcurve", "lightcurve.csv")
```

```bash tab="CLI"
iota-hub drafts files add $ID lightcurve lightcurve.csv
```

With curl, upload the file using the returned `upload_url` and `fields`, as in
step 2. Then finalize it with the returned `file_key`:

```bash
curl -sS -X POST "$IOTA_HUB_API/observations/$ID/files/lightcurve/upload/finalize" \
  -H "X-API-Key: $IOTA_HUB_KEY" -H "Content-Type: application/json" \
  -d '{"file_key": "<file_key from init>", "filename": "lightcurve.csv"}'
```

Replacing a draft's file runs the checks again. To remove a file from a draft,
use `DELETE /observations/{id}/files/{slot}`.

### Dismiss a finding

If a finding is acceptable, dismiss it with a written explanation:

```bash tab="curl"
curl -sS -X POST "$IOTA_HUB_API/observations/$ID/validation/findings/$FINGERPRINT/dismiss" \
  -H "X-API-Key: $IOTA_HUB_KEY" -H "Content-Type: application/json" \
  -d '{"note": "GPS-timed recording; the OWC orbit is out of date for this asteroid."}'
```

```python tab="Python"
client.dismiss_finding(
    obs_id,
    fingerprint,
    note="GPS-timed recording; the OWC orbit is out of date for this asteroid.",
)
```

```bash tab="CLI"
iota-hub drafts dismiss $ID $FINGERPRINT \
  --note "GPS-timed recording; the OWC orbit is out of date for this asteroid."
```

Set `FINGERPRINT` to the finding's fingerprint. Use `DELETE` on the same URL
to undo a dismissal. Missing required items cannot be dismissed.

### Update draft details

Use `PATCH /observations/{id}` to set a comment, select an OWC event, confirm
an asteroid identifier or set `bypass_required_files`. Include the latest
`version` from the observation:

```bash tab="curl"
curl -sS -X PATCH "$IOTA_HUB_API/observations/$ID" \
  -H "X-API-Key: $IOTA_HUB_KEY" -H "Content-Type: application/json" \
  -d '{"version": 7, "comments": "Clouds after R."}'
```

```python tab="Python"
client.update_draft(obs_id, version=7, comments="Clouds after R.")
```

```bash tab="CLI"
iota-hub drafts comment $ID "Clouds after R."   # Reads the version for you
```

Replace `7` with the version you read. If the draft has changed since then,
the API returns `409 stale_version`.

The Hub tries to match the Occult Watcher Cloud (OWC) event after reading the
report. When a Tangra JSON report names one (`optionalData.prediction.owcEventId`),
that event is the link instead, with `owc.choice` set to `report`. The next check
run confirms it on OWC and records the result in `owc.resolution.report_check`:

| `report_check` | Meaning                                                                                      |
| -------------- | -------------------------------------------------------------------------------------------- |
| `verified`     | OWC confirmed the event. It stays the link.                                                  |
| `not_found`    | OWC has no such event. The Hub matched the event itself, as if the report named none.        |
| `mismatch`     | The event is for another asteroid or star. The Hub matched the event itself.                 |
| `unverified`   | OWC could not be reached. The report's event stays the link; the next check run tries again. |

The report's event never blocks a submit. Every upload of a report that names
an event sets it again, replacing a choice you made in between. Accept `choice`
and `report_check` values you do not know.

If the Hub cannot select an event, set `owc_link_choice`:

| Value              | Meaning                                                                              |
| ------------------ | ------------------------------------------------------------------------------------ |
| `picked`           | Select a suggested event. Set `owc_event` to an ID from `owc.resolution.candidates`. |
| `pasted`           | Supply an OWC event ID or URL in `owc_event`. The Hub checks it against the report.  |
| `proceed_unlinked` | Continue without an OWC link.                                                        |

The [reference](/developers/reference) lists all editable fields. To delete an
unsubmitted draft, use `DELETE /observations/{id}`.

## Update a submitted observation

Use the file replacement calls above to correct your submitted observation.
Its status changes to `amended`. A replacement report must describe the same
observation; otherwise, the API returns `422 identity_changed`.

Once the event enters review, the owner can no longer change its files
(`409 already_processed`). Contact a coordinator if a correction is needed.
The observation's `status` reads `locked` while this applies, so check it
before uploading a replacement.

Replacing a file on a submitted observation runs the observer checks again,
but the API does not return their results: the response has `checks: null`.
The results appear on the observation's `web_url`.

## Attachments

You can add up to 25 attachments per observation, each up to 50 MB. Executables
and scripts are not allowed.

Include attachments in the initial file list with `"slot": "attachment"`,
or add them later:

1. Call `POST /observations/{id}/attachments/upload/init` with `filename`.
2. Upload the file using the returned `upload_url` and `fields`.
3. Call `POST /observations/{id}/attachments/upload/finalize` with the
   `file_key`, `attachment_id` and `filename` from the init response. The
   upload itself returns an empty `204`.

The observation lists attachments in `attachments`. To remove one, use
`DELETE /observations/{id}/attachments/{attachment_id}`.

An upload with exactly the same filename as an existing attachment
(case-sensitive) replaces it, so re-uploading every file to update an
observation does not duplicate its attachments. The replacement gets a new
`attachment_id` and does not count against the 25. An attachment a reviewer or
coordinator added is never replaced by the owner's upload; the upload is added
beside it.

## Check for an existing observation

Use `POST /observations/check` before repeating a submission:

```bash tab="curl"
curl -sS -X POST "$IOTA_HUB_API/observations/check" \
  -H "X-API-Key: $IOTA_HUB_KEY" -H "Content-Type: application/json" \
  -d '{"asteroid_id": "1036", "asteroid_name": "Ganymed",
       "star_catalog": "GAIA", "star_id": "1234567890123456789",
       "observed_date": "2026-03-14", "station": null}'
```

```python tab="Python"
answer = client.check_observation(
    asteroid_id="1036",
    asteroid_name="Ganymed",
    star_catalog="GAIA",
    star_id="1234567890123456789",
    observed_date="2026-03-14",
)
```

```bash tab="CLI"
iota-hub observations check --asteroid-id 1036 --asteroid-name Ganymed \
  --star-catalog GAIA --star-id 1234567890123456789 --date 2026-03-14
```

```json
{
  "found": "observation",
  "observation": {
    "observation_id": "3f2b8c1e-6d4a-4f9b-a7e2-91c0d5b84e17",
    "status": "draft",
    "web_url": "..."
  },
  "event": null
}
```

The response's `found` field tells you what matched:

| `found`       | Meaning                                                                                          |
| ------------- | ------------------------------------------------------------------------------------------------ |
| `observation` | A matching draft or submission belongs to you. Its details are in `observation`.                 |
| `event`       | No matching observation belongs to you, but a matching event exists. Its details are in `event`. |
| `none`        | Neither was found.                                                                               |

If an observation was found, use its ID to continue the draft or update the
submission. This lookup does not return another observer's observations.
An event lookup requires `asteroid_id`.

## Read observations and download files

| Endpoint                       | Returns                                                                                   |
| ------------------------------ | ----------------------------------------------------------------------------------------- |
| `GET /events`                  | Events matching the supplied filters                                                      |
| `GET /events/{id}`             | One event                                                                                 |
| `GET /observations`            | Observations matching the supplied filters; use `submission_status=draft` for your drafts |
| `GET /observations/{id}`       | One observation                                                                           |
| `GET /observations/{id}/files` | Observation file download links                                                           |
| `GET /events/{id}/files`       | Event file download links                                                                 |

Lists return one page at a time. Pass the response's `next_cursor` as the
`cursor` query parameter to get the next page. Stop when `next_cursor` is
`null`. The default page size is 25; use `limit` to request up to 100.

The `date_from` and `date_to` filters take an ISO 8601 datetime or date. A
datetime without an offset is UTC. A date means the start of that UTC day for
`date_from` and all of that UTC day for `date_to`.

Download links expire after `expires_in` seconds. Download directly from the
returned URL without sending your API key. Access follows your account
permissions. Event files are normally available when the event is `COMPLETE`;
accounts with permission to view them earlier can do so through the API too.

## Errors

API errors include `code`, `message`, `hint` and `details`. Use `code` in your
error-handling logic, since message wording can change. The
[reference](/developers/reference) lists endpoint-specific codes. Any endpoint
can also return `401`, `403` or `429`, and a request for a missing resource
returns `404`. An invalid body field or query parameter returns `422`
`validation_error`; `details.errors[].loc` names it when the check is per field.

For `429` rate-limit responses, wait for the delay specified by `Retry-After`
before trying again. On submit, `409 submit_in_progress` means another submit of
the draft is still running: request the observation, and call submit again if it
is still a draft with `submit` in `next_actions`. Submitting an observation that
is already submitted returns `200` with its current state. Infrastructure failures may return a different error
format, so check the HTTP status as well.

## Related documentation

- [API keys](/developers/keys)
- [CLI guide](/developers/cli)
- [Python library guide](/developers/library)
- [API reference](/developers/reference)
- [OpenAPI document](/developers/openapi.json)
- [Observer checks](/developers/checks)
- [Data submission requirements](/data-submission)
