{
    "info": {
        "name": "Atomara API",
        "description": "Set the collection variable `apiKey` to a key from the Developers page, then send \"Create a document\" with a PDF in the `file` field. Reference: https://atomara.io/docs/api",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "auth": {
        "type": "bearer",
        "bearer": [
            {
                "key": "token",
                "value": "{{apiKey}}",
                "type": "string"
            }
        ]
    },
    "variable": [
        {
            "key": "baseUrl",
            "value": "https://atomara.io/api/v1"
        },
        {
            "key": "apiKey",
            "value": ""
        },
        {
            "key": "documentId",
            "value": ""
        }
    ],
    "item": [
        {
            "name": "Documents",
            "description": "Send a PDF, read its verdict, list and delete documents.",
            "item": [
                {
                    "name": "Create a document",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Idempotency-Key",
                                "value": "{{$guid}}",
                                "description": "A new unique string for every upload, up to 255 characters — a fresh UUID or your own record id. Repeating the same upload with the same key within 24 hours returns the original document and charges nothing — safe to retry after a timeout. The same key with a different file, `external_id` or `metadata` is refused with `409 idempotency_key_reused`."
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/documents",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "documents"
                            ]
                        },
                        "description": "Upload a PDF and get its analysis. The request waits for the engine for up to 20 seconds:\nmost documents come back `completed` with a `200`. If the analysis takes longer, the answer\nis a `202` with `status: processing` — the analysis continues, and `GET /documents/{id}`\nreturns the result once it is ready.\n\nOne document is one check. Documents the engine cannot analyse (`unsupported`, `failed`)\nare not charged.",
                        "body": {
                            "mode": "formdata",
                            "formdata": [
                                {
                                    "key": "file",
                                    "type": "file",
                                    "src": [],
                                    "description": "The PDF to analyse, as a multipart file. Up to 10 MB and 100 pages; one document is one check,\nwhatever its page count. Scans and photos saved as PDF are accepted and analysed as images."
                                },
                                {
                                    "key": "external_id",
                                    "type": "text",
                                    "value": "tenant-123-payslip",
                                    "description": "Your own reference for this document — an applicant, a case, a row in your database.\nReturned on every read; filter `GET /documents` by it.",
                                    "disabled": true
                                },
                                {
                                    "key": "metadata",
                                    "type": "text",
                                    "value": "{\"applicant_id\":\"A-1029\"}",
                                    "description": "Up to 2 KB of your own key/value data: a JSON object, sent as a string field —\nfor example `{\"applicant_id\":\"A-1029\"}`. Stored and returned as-is; never analysed.",
                                    "disabled": true
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "const body = pm.response.json();",
                                    "if (body && body.id) { pm.collectionVariables.set(\"documentId\", body.id); }"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "List documents",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/documents",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "documents"
                            ],
                            "query": [
                                {
                                    "key": "limit",
                                    "value": "20",
                                    "description": "How many documents to return, newest first.",
                                    "disabled": true
                                },
                                {
                                    "key": "cursor",
                                    "value": "",
                                    "description": "Where to continue from: the `next_cursor` of the previous page. Omit for the first page.",
                                    "disabled": true
                                },
                                {
                                    "key": "external_id",
                                    "value": "tenant-123-payslip",
                                    "description": "Only documents sent with this `external_id`.",
                                    "disabled": true
                                }
                            ]
                        },
                        "description": "Documents sent with your organization's keys, newest first, a page at a time.\nWhile `has_more` is `true`, pass `next_cursor` as `cursor` to get the next page.\nDeleted documents are not listed."
                    }
                },
                {
                    "name": "Retrieve a document",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/documents/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "documents",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "{{documentId}}",
                                    "description": "The document id returned on upload."
                                }
                            ]
                        },
                        "description": "Returns the document and, once `status` is `completed`, its verdict, score and signals.\nWhile it is `processing`, poll every few seconds."
                    }
                },
                {
                    "name": "Delete a document",
                    "request": {
                        "method": "DELETE",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/documents/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "documents",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "{{documentId}}",
                                    "description": "The document id returned on upload."
                                }
                            ]
                        },
                        "description": "Deletes the stored file, the visual report and the analysis immediately, instead of waiting\nfor the 30-day retention to run out. A deleted document answers `404` from then on.\nDeleting does not refund the check."
                    }
                }
            ]
        },
        {
            "name": "Account",
            "description": "Your organization's check balance.",
            "item": [
                {
                    "name": "Retrieve usage",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/usage",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "usage"
                            ]
                        },
                        "description": "How many checks the account has, has used and has left — the same numbers the dashboard\nshows. Checks are shared between the API and documents uploaded in the dashboard."
                    }
                }
            ]
        }
    ]
}