POST/v1/cards
Upload a file as a card
upload_card
Send the document in the file field of a multipart/form-data form. Before saving, Sursa checks that the file name extension, the declared Content-Type of the part and the content signature agree:
- PDF;
- DOCX, XLSX, XLSM, PPTX: a ZIP with the declared main document type;
- ODS: a ZIP with a mimetype entry;
- XLS: an OLE2 document with a workbook stream;
- TXT, MD, CSV, TSV, HTML, AsciiDoc, EML: text without null bytes in UTF-8 or a single-byte encoding, and for email, headers at the start;
- PNG, JPEG, TIFF, WebP, BMP: by signature.
A mismatch returns 415 files.type_mismatch; an extension outside the list of formats returns 415 cards.unsupported_format. A file larger than the installation's upload limit or the organization's total storage under its plan returns 413 files.too_large. When antivirus scanning is enabled, an infected file returns 422 files.infected, and if the scanner is unavailable under the “reject” policy, the request returns 503 files.scan_unavailable. Each rejection is written to the audit log as file.rejected.
Instead of the form, you can send an application/json body (CardUploadFromUpload, since 1.62.0): the file is a ready multipart upload upload_id (POST /v1/uploads with the card_file purpose), the fields are the same as in the form, and tags is a list of strings. The file of the upload was already checked at complete (format, antivirus), and the size limit is the multipart upload limit instead of the single-request upload limit. The upload is used once, in the same transaction that creates the card: an upload already used returns 409 uploads.already_used, one that is not ready yet returns 409 uploads.not_ready, a rejected one returns 422 uploads.rejected, one with another purpose returns 422 uploads.purpose_mismatch, an expired one returns 410 uploads.expired, and another caller's or an unknown upload returns 404 uploads.not_found. If the card checks fail (collection, category, limits), the upload is not used up.
Authentication
Send an API key in the Authorization header: Authorization: Bearer <key>.
Header parameters
Idempotency-KeystringKey for a safe retry of a write: 1 to 255 printable ASCII characters; a UUID v4 per logical operation is recommended. A retry with the same key within 24 hours does not run the operation again: it returns the saved response (status, headers and body) with the
Idempotency-Replayed: trueheader. The same key with a different method, path,Content-Typeor body returns409 api.idempotency_mismatch; while the first request is still running,409 api.idempotency_in_progresswithRetry-After: 1. After a 5xx or 429 response the key is released, and a retry runs the operation again. The key is scoped to the organization and the caller (API key, user, or custom source key).length ≥ 1, length ≤ 255
X-View-AsstringFor API keys with the
adminrole only. Makes the request as the data profile<profile>[:viewer|verifier|editor], for exampleemployee:viewer. The installation key cannot use this header (403).
Cookie parameters
kb_view_asstringCookie of the “View as” mode for a session.
POST /auth/view-assets it andDELETE /auth/view-asclears it.
Request body
multipart/form-data
filestring (application/octet-stream)requiredcollectionstringDefault: "default"
tagsstringDefault: ""
forcebooleanDefault: false
owner_idinteger | nullverify_interval_daysinteger | nullcategorystring | nullsensitiveboolean | nullasyncbooleanDefault: false
reviewbooleanDefault: false
folder_idstring | nullFolder of the
collectionto put the new card in. A folder of another collection returns400 folders.card_collection_mismatch, a missing folder returns404 folders.not_found, and noCOLLECTION_EDIT_CARDSpermission on the folder returns403 authz.forbidden. The check runs before the file is saved. A duplicate of a file that is already uploaded (skipped) is not moved into the folder.length ≤ 64
collection_idinteger | nullCollection by ID. When
collectionis passed too,collection_idwins. A collection that does not exist in the organization or is not visible returns404 collections.not_found.external_idstring | nullexternal_idof the new card. With it, the card is created even if the collection already has the same file. If another card of the organization uses it, the request returns409 cards.external_id_taken. To create or replace a card byexternal_id, usePUT /v1/cards-by-external-id/{external_id}.length ≤ 512
metadatastring | nullmetadataof the new card: a JSON object as the value of the form field. The rules are those ofMetadataPatch.
application/json
upload_idstringrequiredA ready upload (
ready) with thecard_filepurpose; it is used once.collectionstringDefault: "default"
collection_idinteger | nullCollection by ID. When
collectionis passed too,collection_idwins. A collection that does not exist in the organization, is not visible or is outside the collections of the key returns404 collections.not_found.tagsarray of stringitems ≤ 30
forcebooleanDefault: false
owner_idinteger | nullverify_interval_daysinteger | nullcategorystring | nullsensitiveboolean | nullasyncbooleanDefault: false
reviewbooleanDefault: false
folder_idstring | nulllength ≤ 64
external_idstring | nullexternal_idof the new card, as in the form field. With it, the card is created even if the collection already has the same file. If another card of the organization uses it, the request returns409 cards.external_id_taken.length ≤ 512
metadataMetadataPatch
Responses
200`queued` (asynchronous), `skipped` (duplicate), `ready` or `error` (synchronous).
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
Idempotency-Replayedtruemeans the response was replayed from the saved one for thisIdempotency-Key: the operation did not run again.
application/json
400The request is invalid: a parameter value or the state of the object does not allow the action (`detail` is a message).
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
401No credentials were sent (neither a session cookie nor an API key), or the key was not found.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
402The organization has reached a plan limit (cards, storage or users). `error.details` holds `kind`, `limit` and `used`.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
403The action is not allowed: the role is insufficient, there is no access to the collection or card, the request runs in “View as” mode, or the organization is suspended or deleted (`detail` is an object with `code: org_suspended | org_deleted`).
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
404The object does not exist or is not available to you. The API does not confirm that a restricted object exists.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
409The state of the object does not allow the action, for example a duplicate, indexing in progress, or a job that is already processed.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
410The object existed but is no longer available: the link was used or has expired, or the file was deleted at the end of its retention period.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
413The request body exceeds the allowed size.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
415The file format is not supported.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
422Validation error: the body or parameters do not match the schema (`detail` is a list of validation errors), or a parameter value is out of range (`detail` is a message).
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
429Too many requests (`api.rate_limited`), the organization's quota for the minute, day or month is used up (`api.quota_exceeded`; `error.details` holds `quota`, `limit` and `reset_at`), the organization's limit is reached, or the answer service is busy (`answers.engine_busy`). Wait for the time in the `Retry-After` header.
Response headers
Retry-AfterNumber of seconds to wait before you retry the request.
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
503A service that this request depends on is temporarily unavailable. Retry later.
Response headers
RateLimit-PolicyLimits in effect, in the format of the IETF draft
draft-ietf-httpapi-ratelimit-headers: comma-separated items"<name>";q=<quota>;w=<window in seconds>.keyis the request rate of the API key (the quota is the burst, the window is the time to refill it fully; for a session it isuser, without credentialsip);minute,dayandmonthare the organization's quotas for the calendar minute, day and month in UTC.RateLimitWhat is left of each limit in
RateLimit-Policy:"<name>";r=<remaining>;t=<seconds until reset>.X-RateLimit-LimitLimit of the strictest entry in
RateLimit-Policy(the one with the fewest requests left).X-RateLimit-RemainingRequests left under the strictest limit.
X-RateLimit-ResetSeconds until the strictest limit resets.
application/json
Error codes
Codes this endpoint can return in error.code, besides the general codes of every request.
- 400api.metadata_invalid
- 409api.idempotency_in_progress
- 400api.idempotency_key_invalid
- 409api.idempotency_mismatch
- 401auth.not_authenticated
- 403auth.system_scope
- 403authz.forbidden
- 403cards.duplicate_restricted
- 409cards.external_id_taken
- 403cards.no_access
- 404cards.not_found
- 400cards.review_requires_async
- 403cards.sensitivity_admin_only
- 415cards.unsupported_format
- 400categories.unknown
- 409collections.index_outdated
- 400collections.invalid_name
- 403collections.no_write_access
- 404collections.not_found
- 422files.infected
- 503files.scan_unavailable
- 413files.too_large
- 415files.type_mismatch
- 400folders.card_collection_mismatch
- 404folders.not_found
- 404jobs.not_found
- 402limits.cards
- 403org.deleted
- 403org.suspended
- 409uploads.already_used
- 410uploads.expired
- 404uploads.not_found
- 409uploads.not_ready
- 422uploads.purpose_mismatch
- 422uploads.rejected
- 400users.not_in_org
- 422validation.failed
- 403view_as.read_only
Safe retries
Send an Idempotency-Key header (for example a UUID) with each POST and PATCH. A retry with the same key within 24 hours returns the saved response instead of running the request again.
Rate limits
Responses carry the RateLimit and RateLimit-Policy headers and the earlier X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. A 429 response has Retry-After in seconds: wait and retry.