> For the complete documentation index, see [llms.txt](https://detected.gitbook.io/detected-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://detected.gitbook.io/detected-api-docs/api-reference/documents.md).

# Documents

Documents can be uploaded to profiles as part of onboarding. Document types are first set up in the document library, and each document type can have settings such as accepted file types, size limits and workflow steps (for example fraud checks and translations). A profile can have multiple documents. To upload documents to a profile, see the Documents sub-section of Profiles.

## List document library types

> Returns all the document types from the document library. Each type is made up of the specific settings that have been configured to process that document type. Pass a document type's ID as \`libraryId\` to \*\*Upload documents to a profile\*\* (\`POST /profiles/{uuid}/documents/{libraryId}\`) so the document is processed based on those settings.

```json
{"openapi":"3.0.0","info":{"title":"Detected API","version":"v2"},"tags":[{"name":"Documents","description":"Documents can be uploaded to profiles as part of onboarding. Document types are first set up in the document library, and each document type can have settings such as accepted file types, size limits and workflow steps (for example fraud checks and translations). A profile can have multiple documents. To upload documents to a profile, see the Documents sub-section of Profiles."}],"servers":[{"url":"https://api.detected.app/api/v2/public","description":"Production"}],"security":[{"AccessToken":[]}],"components":{"securitySchemes":{"AccessToken":{"type":"http","description":"The API uses OAuth 2.0. Request an access token with **Create an access token** (`POST /oauth/token`), sending the client ID and client secret of your integration client, and your account slug. Send the access token in the `Authorization` header of every request, in the format `Authorization: Bearer <access_token>`. The access token carries the scopes set on your integration client in the dashboard. Access tokens expire. When one expires, request a new one.","bearerFormat":"OAuth 2.0 access token","scheme":"bearer"}},"headers":{"X-RateLimit-Limit":{"description":"Maximum number of requests allowed in the rate limit window.","schema":{"type":"number","nullable":false}},"X-RateLimit-Remaining":{"description":"Number of requests remaining in the current rate limit window.","schema":{"type":"number","nullable":false}},"Retry-After":{"description":"Number of seconds to wait before making another request. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}},"X-RateLimit-Reset":{"description":"Unix timestamp (in seconds) at which the rate limit resets. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}}},"schemas":{"DocumentLibraryListResponse":{"title":"Document Library List Response","required":["id","name","type","label"],"properties":{"id":{"description":"ID of the document type. Use it as `libraryId` when uploading documents with **Upload documents to a profile** (`POST /profiles/{uuid}/documents/{libraryId}`).","type":"integer","nullable":false},"name":{"description":"Name of the document type, as set up in your account.","type":"string","nullable":false},"type":{"description":"Category code of the document type, for example `account_statement`.","type":"string","nullable":false},"label":{"description":"Display label for the category, for example `Account statement`.","type":"string","nullable":false}},"type":"object"}},"responses":{"401":{"description":"Unauthorized. The access token is missing, invalid or has expired.","content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}},"429":{"description":"Too Many Requests. You have exceeded the rate limit. Wait for the number of seconds given in the `Retry-After` header before trying again.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}}}},"paths":{"/documents/libraries":{"get":{"tags":["Documents"],"summary":"List document library types","description":"Returns all the document types from the document library. Each type is made up of the specific settings that have been configured to process that document type. Pass a document type's ID as `libraryId` to **Upload documents to a profile** (`POST /profiles/{uuid}/documents/{libraryId}`) so the document is processed based on those settings.","operationId":"c4c0748e10b7443b29265a34979f35bd","responses":{"200":{"description":"OK","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"properties":{"data":{"description":"List of document libraries","type":"array","items":{"$ref":"#/components/schemas/DocumentLibraryListResponse"}}},"type":"object"}}}},"401":{"$ref":"#/components/responses/401"},"429":{"$ref":"#/components/responses/429"}}}}}}
```

## List documents

> Returns all documents that have been uploaded to any profiles in the account. Use the query parameters to filter the results by profile. Use the ID of each document to get its details with \*\*Retrieve a document\*\* (\`GET /documents/{id}\`).

```json
{"openapi":"3.0.0","info":{"title":"Detected API","version":"v2"},"tags":[{"name":"Documents","description":"Documents can be uploaded to profiles as part of onboarding. Document types are first set up in the document library, and each document type can have settings such as accepted file types, size limits and workflow steps (for example fraud checks and translations). A profile can have multiple documents. To upload documents to a profile, see the Documents sub-section of Profiles."}],"servers":[{"url":"https://api.detected.app/api/v2/public","description":"Production"}],"security":[{"AccessToken":[]}],"components":{"securitySchemes":{"AccessToken":{"type":"http","description":"The API uses OAuth 2.0. Request an access token with **Create an access token** (`POST /oauth/token`), sending the client ID and client secret of your integration client, and your account slug. Send the access token in the `Authorization` header of every request, in the format `Authorization: Bearer <access_token>`. The access token carries the scopes set on your integration client in the dashboard. Access tokens expire. When one expires, request a new one.","bearerFormat":"OAuth 2.0 access token","scheme":"bearer"}},"parameters":{"order_by":{"name":"order_by","in":"query","description":"Direction to sort the results in: `asc` for ascending or `desc` for descending. Use it together with `sort_by`; it has no effect if `sort_by` is omitted. The default is `asc`.","schema":{"type":"string","enum":["desc","asc"]}},"page":{"name":"page","in":"query","description":"Page number of the results to return, starting from 1. The number of items per page is returned in `meta.per_page`.","schema":{"type":"integer","minimum":1}}},"headers":{"X-RateLimit-Limit":{"description":"Maximum number of requests allowed in the rate limit window.","schema":{"type":"number","nullable":false}},"X-RateLimit-Remaining":{"description":"Number of requests remaining in the current rate limit window.","schema":{"type":"number","nullable":false}},"Retry-After":{"description":"Number of seconds to wait before making another request. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}},"X-RateLimit-Reset":{"description":"Unix timestamp (in seconds) at which the rate limit resets. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}}},"schemas":{"DocumentListResponse":{"title":"Document List Response","required":["id","profile_id","library_id","category","name","created_at","updated_at"],"properties":{"id":{"description":"ID of the document.","type":"integer","nullable":false},"profile_id":{"description":"UUID of the profile the document belongs to.","type":"string","format":"uuid","nullable":false},"library_id":{"description":"UUID of the document type the document was uploaded against, or `null` if it was not uploaded against one, for example a signature. Use it to group documents by type. This is not the integer ID returned by **List document library types** (`GET /documents/libraries`) and used to upload documents.","type":"string","format":"uuid","nullable":true},"category":{"description":"Name of the document type at the time the document was uploaded. If the type has since been renamed, this keeps the old name, so use `library_id` to group documents by type.","type":"string","nullable":false},"name":{"description":"Name of the document. Currently the same as `category`.","type":"string","nullable":false},"updated_at":{"description":"Date and time the document was last updated.","type":"string","nullable":false},"created_at":{"description":"Date and time the document was created.","type":"string","nullable":false}},"type":"object"},"LinksResource":{"title":"Links Resource","properties":{"first":{"description":"URL of the first page of results.","type":"string","nullable":false},"last":{"description":"URL of the last page of results.","type":"string","nullable":false},"prev":{"description":"URL of the previous page of results, or null if there is none.","type":"string","nullable":true},"next":{"description":"URL of the next page of results, or null if there is none.","type":"string","nullable":true}},"type":"object"},"MetaResource":{"title":"Meta Resource","properties":{"current_page":{"description":"Number of the current page.","type":"integer","nullable":false},"from":{"description":"Position of the first item on this page, counted across all pages, or `null` if there are no results.","type":"integer","nullable":true},"last_page":{"description":"Number of the last page.","type":"integer","nullable":false},"links":{"description":"Pagination links, including links to the previous and next pages.","type":"array","items":{"properties":{"url":{"description":"URL of the page, or `null` if there is no such page.","type":"string","nullable":true},"label":{"description":"Text to display for the link, for example a page number or \"Previous\".","type":"string","nullable":false},"page":{"description":"Number of the page the link points to, or `null` if there is no such page.","type":"integer","nullable":true},"active":{"description":"Whether this link is for the current page.","type":"boolean","nullable":false}},"type":"object"},"nullable":false},"path":{"description":"Base URL of the endpoint, without query parameters.","type":"string","nullable":false},"per_page":{"description":"Number of items per page.","type":"integer","nullable":false},"to":{"description":"Position of the last item on this page, counted across all pages, or `null` if there are no results.","type":"integer","nullable":true},"total":{"description":"Total number of items across all pages.","type":"integer","nullable":false}},"type":"object"}},"responses":{"401":{"description":"Unauthorized. The access token is missing, invalid or has expired.","content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}},"429":{"description":"Too Many Requests. You have exceeded the rate limit. Wait for the number of seconds given in the `Retry-After` header before trying again.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}}}},"paths":{"/documents":{"get":{"tags":["Documents"],"summary":"List documents","description":"Returns all documents that have been uploaded to any profiles in the account. Use the query parameters to filter the results by profile. Use the ID of each document to get its details with **Retrieve a document** (`GET /documents/{id}`).","operationId":"f90fe4444f34d192763febd41979d140","parameters":[{"name":"id","in":"query","description":"Filter by document ID. If a match is found, only that document is returned.","schema":{"type":"integer"}},{"$ref":"#/components/parameters/order_by"},{"name":"sort_by","in":"query","description":"The field to sort the results by. Use it together with `order_by` to choose the direction; if `order_by` is omitted, results are sorted in ascending order (`asc`). If `sort_by` is omitted, results are returned in no guaranteed order.\n\nSupported fields:\n- `created_at`\n- `updated_at`\n- `id`\n- `profile_id`\n- `document_id`\n- `category`\n- `name`\n","schema":{"type":"string"}},{"$ref":"#/components/parameters/page"},{"name":"profile_id","in":"query","description":"Filter by profile UUID. Returns the documents that belong to that profile.","schema":{"type":"string","format":"uuid"}},{"name":"category","in":"query","description":"Filter by document category.","schema":{"type":"string"}},{"name":"name","in":"query","description":"Filter by document name.","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"properties":{"data":{"description":"List of documents","type":"array","items":{"$ref":"#/components/schemas/DocumentListResponse"}},"links":{"$ref":"#/components/schemas/LinksResource"},"meta":{"$ref":"#/components/schemas/MetaResource"}},"type":"object"}}}},"401":{"$ref":"#/components/responses/401"},"429":{"$ref":"#/components/responses/429"}}}}}}
```

## Retrieve a document

> Returns a single document, including a temporary link to download it and the results of processing, such as OCR, translation and fraud analysis. The download link expires after one hour, at \`link\_expires\_at\`.

```json
{"openapi":"3.0.0","info":{"title":"Detected API","version":"v2"},"tags":[{"name":"Documents","description":"Documents can be uploaded to profiles as part of onboarding. Document types are first set up in the document library, and each document type can have settings such as accepted file types, size limits and workflow steps (for example fraud checks and translations). A profile can have multiple documents. To upload documents to a profile, see the Documents sub-section of Profiles."}],"servers":[{"url":"https://api.detected.app/api/v2/public","description":"Production"}],"security":[{"AccessToken":[]}],"components":{"securitySchemes":{"AccessToken":{"type":"http","description":"The API uses OAuth 2.0. Request an access token with **Create an access token** (`POST /oauth/token`), sending the client ID and client secret of your integration client, and your account slug. Send the access token in the `Authorization` header of every request, in the format `Authorization: Bearer <access_token>`. The access token carries the scopes set on your integration client in the dashboard. Access tokens expire. When one expires, request a new one.","bearerFormat":"OAuth 2.0 access token","scheme":"bearer"}},"parameters":{"documentId":{"name":"id","in":"path","description":"ID of the document.","required":true,"schema":{"type":"integer","nullable":false}}},"headers":{"X-RateLimit-Limit":{"description":"Maximum number of requests allowed in the rate limit window.","schema":{"type":"number","nullable":false}},"X-RateLimit-Remaining":{"description":"Number of requests remaining in the current rate limit window.","schema":{"type":"number","nullable":false}},"Retry-After":{"description":"Number of seconds to wait before making another request. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}},"X-RateLimit-Reset":{"description":"Unix timestamp (in seconds) at which the rate limit resets. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}}},"schemas":{"DocumentViewResponse":{"title":"Document View Response","required":["id","profile_id","library_id","category","name","link","file_type","link_expires_at","created_at","updated_at"],"properties":{"id":{"description":"ID of the document.","type":"integer","nullable":false},"profile_id":{"description":"UUID of the profile the document belongs to.","type":"string","format":"uuid","nullable":false},"library_id":{"description":"UUID of the document type the document was uploaded against, or `null` if it was not uploaded against one, for example a signature. Use it to group documents by type. This is not the integer ID returned by **List document library types** (`GET /documents/libraries`) and used to upload documents.","type":"string","format":"uuid","nullable":true},"category":{"description":"Name of the document type at the time the document was uploaded. If the type has since been renamed, this keeps the old name, so use `library_id` to group documents by type.","type":"string","nullable":false},"name":{"description":"Name of the document. Currently the same as `category`.","type":"string","nullable":false},"link":{"description":"Temporary URL to download the document. It stops working at the time given in `link_expires_at`.","type":"string","nullable":false},"file_type":{"description":"File type of the document.","type":"string","nullable":false},"link_expires_at":{"description":"Date and time at which `link` expires.","type":"string","nullable":false},"fraud_check":{"description":"Results of the AI fraud analysis of the document.","properties":{"processed_at":{"description":"Date and time the fraud analysis was processed.","type":"string","nullable":true},"analysis":{"description":"Details of the fraud analysis.","properties":{"score":{"description":"Fraud risk category of the document, for example `High Risk` or `Warning`. `null` if no fraud check was run.","type":"string"},"document_type":{"description":"Type of document identified, in plain language.","type":"string"},"meta_data":{"description":"Metadata embedded in the document.","properties":{"producer":{"description":"Software that produced the file, from its metadata.","type":"string","nullable":true},"creator":{"description":"Software that created the original document, from its metadata.","type":"string","nullable":true},"creation_date":{"description":"Date the document was created, from its metadata.","type":"string","nullable":true},"mod_date":{"description":"Date the document was last modified, from its metadata.","type":"string","nullable":true},"author":{"description":"Author of the document, from its metadata.","type":"string","nullable":true},"keywords":{"description":"Keywords in the document metadata, separated by commas.","type":"string","nullable":true},"subject":{"description":"Subject of the document, from its metadata.","type":"string","nullable":true},"title":{"description":"Title of the document, from its metadata.","type":"string","nullable":true}},"type":"object"},"indicators":{"description":"Fraud indicators detected in the document.","type":"array","items":{"properties":{"type":{"description":"Type of fraud indicator: `RISK` for a sign of fraud, `TRUST` for a sign the document is genuine, or `INFO` for information only.","type":"string"},"category":{"description":"Category of the fraud indicator, for example `synthetic_document`, `content`, `model_matched`, `metadata`, `document_structure`, `document_origin`, `producer` or `quality`.","type":"string"},"title":{"description":"Short title of the fraud indicator.","type":"string"},"description":{"description":"Explanation of what was detected.","type":"string"}},"type":"object"}}},"type":"object","nullable":true}},"type":"object","nullable":true},"translation":{"description":"Translation of the document.","properties":{"status":{"description":"Status of the translation: `complete` when the translation has finished, or `null` if the document was not translated.","type":"string","nullable":true},"link":{"description":"Temporary URL to download the translated document. It stops working at the time given in `link_expires_at`.","type":"string","nullable":true},"file_type":{"description":"File type of the translated document.","type":"string","nullable":true},"link_expires_at":{"description":"Date and time at which `link` expires.","type":"string","nullable":true},"extracted":{"description":"Translated text of the document.","type":"string","nullable":true}},"type":"object","nullable":true},"ocr":{"description":"Text extracted from the original document using OCR.","properties":{"extracted":{"description":"Text extracted from the document.","type":"string","nullable":true}},"type":"object","nullable":true},"updated_at":{"description":"Date and time the document was last updated.","type":"string","nullable":false},"created_at":{"description":"Date and time the document was created.","type":"string","nullable":false}},"type":"object"}},"responses":{"401":{"description":"Unauthorized. The access token is missing, invalid or has expired.","content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}},"404":{"description":"Not Found. The requested resource does not exist, or is not available to your account.","content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"},"error":{"description":"Machine-readable details of the error.","type":"object","properties":{"key":{"description":"Error code, for example `error.generic`.","type":"string"},"params":{"description":"Values used in the error message, if any.","type":"array","items":{}}}}},"type":"object"}}}},"429":{"description":"Too Many Requests. You have exceeded the rate limit. Wait for the number of seconds given in the `Retry-After` header before trying again.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}}}},"paths":{"/documents/{id}":{"get":{"tags":["Documents"],"summary":"Retrieve a document","description":"Returns a single document, including a temporary link to download it and the results of processing, such as OCR, translation and fraud analysis. The download link expires after one hour, at `link_expires_at`.","operationId":"e58e42696daf0c0d06c54728f3da6615","parameters":[{"$ref":"#/components/parameters/documentId"}],"responses":{"200":{"description":"OK","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/DocumentViewResponse"}},"type":"object"}}}},"401":{"$ref":"#/components/responses/401"},"404":{"$ref":"#/components/responses/404"},"429":{"$ref":"#/components/responses/429"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://detected.gitbook.io/detected-api-docs/api-reference/documents.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
