Apilyn DocsDeveloper portal

API recipes

Companion to QUICKSTART.md. These recipes assume a sandbox API key (sk_test_…) and X-Org-Id. Full curl bootstrap lives in the quickstart.

Executable samples (Python/TypeScript) live under sdk/samples/.

Async job: upload → complete → create → poll → download

  1. POST /v1/uploads — receive id + upload_url (never a storage key).
  2. PUT bytes to upload_url with returned headers.
  3. POST /v1/uploads/{id}/complete — intake/malware gate; status becomes

ready_for_processing (or rejection with a storage/intake error.code).

  1. POST /v1/jobs with Idempotency-Key and inputs.upload_ids.
  2. Poll GET /v1/jobs/{job_id} until terminal:

completed | failed | cancelled | expired.

  1. GET /v1/jobs/{job_id}/outputs/{alias}/download — signed URL for the artifact.

Job lifecycle: queued → running → completed|failed|cancelled|expired.

Sync tool vs async job

Sync toolAsync job
EndpointPOST /v1/tools/{tool_name}POST /v1/jobs
Body{ "parameters": { … } }pipeline + upload inputs
Response200 with output immediately202 job id; poll for artifacts
Use whenStructured/text ops (JSON, CSV, GEO, …)Files / OCR / Office / web capture / AI docs

List both surfaces via GET /v1/operations?execution_mode=sync_tool|async_job.

Example sync call:

curl -sS -X POST "$APILYN_API_URL/v1/tools/json.format" \
  -H "Authorization: Bearer $APILYN_API_KEY" \
  -H "X-Org-Id: $APILYN_ORG_ID" \
  -H "Content-Type: application/json" \
  -d '{"parameters":{"text":"{\"b\":1,\"a\":2}","indent":2,"sort_keys":true}}'

Idempotency

  • Required header on POST /v1/jobs: Idempotency-Key (≤128 chars).
  • Same key + same payload fingerprint → replay (200 with existing job).
  • Same key + different payload → 409 with error.code=idempotency_conflict.
  • Keys are scoped per organization.

Webhook signing

See WEBHOOKS.md. Summary:

  • Headers: X-Apilyn-Signature, X-Apilyn-Timestamp, X-Apilyn-Event-Id,

X-Apilyn-Event-Type

  • Signature format: t=<unix>,v1=<hmac_sha256_hex>
  • Signed payload: "{timestamp}." + raw_body (raw body is canonical JSON)

Error handling

Always parse:

{ "error": { "code": "…", "message": "…", "details": {}, "request_id": "…" } }

Catalog: ERROR_CODES.md.

Contract freeze checks

make openapi-check
make openapi-lint
make openapi-diff
make sdk-check
make sdk-smoke