# Resguarda API integration guide The Resguarda API lets an external application read assets, risks, vendors, and eligible compliance tests, discover existing evidence requests, upload evidence, and read the resulting review and test states in one organization. It accepts ordinary files from any integration. Uploads submit evidence for the existing workflow; the caller cannot set a test result, approve evidence, create requests, or publish a policy. Use any server-side HTTP client or automation platform that supports HTTPS and bearer authentication. Set `API_BASE_URL` to your Resguarda application origin, without a trailing slash. The variables in the examples are caller configuration, not additional Resguarda server settings. - Public guide: [/api-docs](/api-docs). - Browse endpoints and schemas: [API reference](/api-docs/reference). - Machine-readable OpenAPI 3.2 specification: [/api-docs/openapi.json](/api-docs/openapi.json). The `openapi` field (`3.2.0`) is the specification format version. The separate `info.version` (`1.2.0-candidate`) is the API contract version. This version adds list and detail reads for the asset, risk, and vendor registers. The upload `file` part is described as raw bytes sent with your own media type, matching what the endpoint has always accepted. These documentation URLs are public. All register, test, and evidence data requires an API token. ## Credentials and organization scope An active Owner or Admin in the organization issues tokens in the app under **Account → API tokens** (`//account#api-tokens`): choose **Create token**, enter a name, select scopes, pick an expiry of 7, 30, or 90 days, and copy the secret from the one-time dialog. The same page revokes tokens. Automation can use the session API instead: `POST /api/workspaces//api-tokens` with `name`, a nonempty unique subset of `control_test:read`, `evidence:submit`, `asset:read`, `risk:read`, and `vendor:read` in `scopes`, and an optional `expiresAt` ISO datetime. Credential management requires that administrator's authenticated browser session; issuing and revoking also require the session's `x-csrf-token` header. Tenant session calls without the workspace prefix return `400 WORKSPACE_REQUIRED`. Bearer credentials cannot manage other credentials. `GET /api/workspaces//api-tokens` lists safe metadata, and `DELETE /api/workspaces//api-tokens/{id}` revokes a token. Issuance returns `{ secret, token }` once; the app shows the secret only in the creation dialog. Store `secret` in your integration's secret store as `RESGUARDA_API_TOKEN`. Do not put it in a URL, source control, shared logs, or browser-delivered code. Subsequent credential listings do not return the secret. Use `control_test:read` for test reads and `evidence:submit` for uploads and request status. Request discovery requires both scopes. Existing read-only tokens retain their original permissions; issue a replacement with the needed scopes. They have a finite expiry: the default and maximum lifetime is 90 days, and a requested expiry must be in the future. Tokens cannot be refreshed. To rotate one, issue a replacement, update and verify your integration, then revoke the old token. Revoke a compromised credential immediately. Each token is bound to its issuing organization. Cookies and request parameters cannot switch that organization. The organization and issuing Owner/Admin must remain active; removing or suspending the issuer, deleting their account, or changing their role so they are no longer an Owner/Admin disables their tokens. A browser session alone does not authenticate these integration endpoints. ## Read assets, risks, and vendors Choose just the scopes the integration needs when issuing its token. Each scope covers a collection and individual records in the issuing organization. | Collection | Scope | Search and filters | | --- | --- | --- | | `GET /api/v1/assets` | `asset:read` | Search name or source ID with `q`. Filter by `assetType`, `status`, `criticality`, or `ownerMembershipId`. | | `GET /api/v1/risks` | `risk:read` | Search title or code. Filter by `status`, `ownerMembershipId`, or `band`. The `axis` parameter selects inherent (default) or residual scoring using the organization's thresholds. | | `GET /api/v1/vendors` | `vendor:read` | Search name, description, or services. Filter by `lifecycleStatus`, `criticality`, or `reviewOverdue=true`. Overdue reviews follow the organization's cadence. | For example, call `GET /api/v1/vendors?reviewOverdue=true&pageSize=25` with the bearer header. Each list returns `items`, `page`, `pageSize`, and `hasMore`. Keep filters fixed and advance until `hasMore` is false, including after an empty or short page. Changes during traversal can shift results. Names and source identifiers can match multiple records. Append the selected ID to its collection URL to get detail, such as `GET /api/v1/vendors/{id}`. The JSON body contains public record fields and the `ETag` header contains the quoted revision. Lists and details exclude records in trash. A missing or inaccessible ID returns 404. Register reads consume shared IP, credential, and organization budgets. ## Read tests Send `Authorization: Bearer ${RESGUARDA_API_TOKEN}` on every request. Successful responses are JSON. API data and credential responses use `Cache-Control: private, no-store`. | Method and path | Result | | --- | --- | | `GET /api/v1/tests?page=1&pageSize=25` | `{ items, page, pageSize, hasMore }` | | `GET /api/v1/tests/{id}` | One eligible test visible to the token's organization | ```sh curl --fail-with-body \ --header "Authorization: Bearer ${RESGUARDA_API_TOKEN}" \ "${API_BASE_URL}/api/v1/tests?page=1&pageSize=25" ``` Set `RESGUARDA_TEST_ID` to an ID returned by the list. URL-encode the ID as a single path segment if your HTTP client does not do that for you. ```sh curl --fail-with-body \ --header "Authorization: Bearer ${RESGUARDA_API_TOKEN}" \ "${API_BASE_URL}/api/v1/tests/${RESGUARDA_TEST_ID}" ``` Test metadata includes identity, catalog reference, name and description, source, category, domain, type and family, status, cadence, and creation/update timestamps. Nullable values remain null. The OpenAPI specification defines the fields and allowed values. Responses exclude evidence/file contents, personnel data, credentials, and raw provider records. Disabled, deleted, or otherwise ineligible tests are unavailable. ## Upload evidence for an existing request | Method and path | Required scope | Result | | --- | --- | --- | | `GET /api/v1/tests/{id}/evidence-requests` | Both scopes | Eligible OPEN/REJECTED requests, using the pagination below. | | `POST /api/v1/evidence-requests/{id}/submissions` | `evidence:submit` | Stable receipt, request, submission, evidence, exact version, and file IDs. | | `GET /api/v1/evidence-requests/{id}` | `evidence:submit` | Separate request, submission, artifact review, test result, and current coverage states. | Discover a request for a test returned by the tests API. Empty discovery means there is no currently eligible request to upload to. A workspace user must configure the requirement through the application first. ```sh curl --fail-with-body \ --header "Authorization: Bearer ${RESGUARDA_API_TOKEN}" \ "${API_BASE_URL}/api/v1/tests/${RESGUARDA_TEST_ID}/evidence-requests?page=1&pageSize=25" ``` Select a returned request ID as `RESGUARDA_REQUEST_ID`. Save a unique `IDEMPOTENCY_KEY` for this submission before uploading. A UUID is suitable; keys accept 1 to 128 letters, digits, dots, underscores, colons, or hyphens. Reuse that key with exactly the same request, file name, content type, file bytes, title, and note whenever retrying this submission. The maximum file size is **4 MiB (4,194,304 bytes)**. The complete multipart body, including boundaries and metadata, must be at most **4,400,000 bytes**. Send exactly one `file`, one `title` (1 to 200 characters), and an optional `note` (up to 2,000 characters). The file must be one of the allowed types (pdf, docx, xlsx, pptx, odt, txt, md, csv, png, jpg, jpeg, webp) and its content must match its extension: a file named `report.pdf` must start with a PDF header. Archives (zip, 7z, rar, tar, gz), macro-enabled and legacy Office files (docm, xlsm, doc, xls, rtf) and active content (html, svg, xml, js) are rejected with a 400 that names the allowed types. Empty files, unknown fields, and duplicate fields are rejected. The server derives the organization and assessment context. ```sh curl --fail-with-body \ --header "Authorization: Bearer ${RESGUARDA_API_TOKEN}" \ --header "Idempotency-Key: ${IDEMPOTENCY_KEY}" \ --form "file=@fictional-acceptance.csv;type=text/csv" \ --form-string "title=Policy acceptance export" \ --form-string "note=Source export for independent review" \ "${API_BASE_URL}/api/v1/evidence-requests/${RESGUARDA_REQUEST_ID}/submissions" ``` A successful initial upload and a completed replay both return HTTP 200 with `{ receiptId, requestId, submissionId, evidenceId, evidenceVersionId, fileId }`. These IDs confirm submission. Read fresh state separately, passing the returned `submissionId` to keep the response tied to that exact submission: ```sh curl --fail-with-body \ --header "Authorization: Bearer ${RESGUARDA_API_TOKEN}" \ "${API_BASE_URL}/api/v1/evidence-requests/${RESGUARDA_REQUEST_ID}?submissionId=${RESGUARDA_SUBMISSION_ID}" ``` Without `submissionId`, status returns the latest submission. Before the first submission, submission and evidence are null. Missing or inaccessible requests and submissions return 404. Status never returns file bytes, download URLs, storage locations, or reviewer identities. A reviewed document-supply requirement may produce a PASSING supply result while the request remains IN_REVIEW and its artifact awaits approval. Read these states separately. A file titled as a policy acceptance export does not establish employee acceptance, control effectiveness, or publication. The token issuer cannot approve the evidence that their token submitted. Files currently have scanning status SKIPPED; this records that no malware scan occurred. An older eligible request can still receive evidence after a newer request exists. That historical submission stays available for review and does not replace the test's current result. Automatic document-supply evaluation applies only to the current request, selected by creation time and then request ID. A successful submission also creates the normal in-app notification for its requester; completed retries do not notify again. ### Safe retries and rotation Keys are unique across the organization. Reusing a key for changed content or another request returns 409 with `error.details.reason: IDEMPOTENCY_MISMATCH`. A matching upload with an active lease returns 409 with `error.details.reason: UPLOAD_IN_PROGRESS` and `Retry-After: 2`. Wait at least that many seconds before a bounded retry of the same saved key and payload. If the outcome is uncertain after a connection failure, retry with the same saved key and payload. Do not generate a new key automatically, since that represents a new submission. Upload conflicts retain HTTP 409 and `error.code: CONFLICT`. Starting with contract `1.1.1-candidate`, `error.details.reason` identifies the cause without exposing tenant, issuer or storage identifiers. Only `UPLOAD_IN_PROGRESS` permits automatic conflict retry. Other reasons require caller action or investigation: | Reason | Meaning | | --- | --- | | `IDEMPOTENCY_MISMATCH` | The key was used for another request or different payload. | | `ISSUER_MISMATCH` | Pending recovery requires the original issuer. | | `REQUEST_CHANGED` | The request's scope or state changed. | | `STORAGE_MISMATCH` | The reserved object's bytes do not match. | | `LEASE_EXPIRED` | This claimant lost its lease or generation. | | `RESERVATION_CHANGED` | The reservation changed or its creation raced. | | `TOKEN_INACTIVE` | The token became inactive before attachment. | | `RECEIPT_INCOMPLETE` | A completed receipt lacks required identifiers. | | `CLOCK_UNAVAILABLE` | A database clock value was unavailable. | These nonautomatic cases may permit later recovery after investigation, always using the original key and payload when retrying the same submission. Never classify conflicts by message text. Older servers and future reasons must fail closed: absent or unknown reasons do not authorize automatic retry. Bound the retry count and wait budget; if `Retry-After` exceeds the wait budget, stop and retain the saved upload for later recovery. A retry receipt confirms submission only. Completed receipts can be replayed by another currently authorized token in the same organization. Recovering a pending upload after token rotation requires a replacement issued by the same person. A different issuer receives a conflict requiring operator investigation. Retain the original file and metadata until the receipt has been confirmed. A stored object can be recovered after an interrupted attachment, without overwriting it or creating duplicate evidence. ## Pagination The list defaults to `page=1` and `pageSize=25`. Page size must be an integer from 1 to 100; page must be an integer from 1 to 10000. 1. Start at page 1 and keep the same page size throughout a traversal. 2. Process the returned `items`. An empty or short page can still have `hasMore: true` because eligibility filtering occurs after a bounded set of candidates is selected. 3. If `hasMore` is false, the traversal is finished. Otherwise increment the page, even when `items` was empty. 4. If page 10000 still has `hasMore: true`, stop and report the traversal as incomplete. Do not request page 10001 or claim that all tests were retrieved. Concurrent changes can move records between pages. Deduplicate by test ID if needed; this interface does not provide a snapshot export. ## Errors and retries Errors have the JSON shape `{ "error": { "code": "...", "message": "..." } }` and may include `error.details`. Use the HTTP status and error code for handling; do not depend on exact message text. | Status | Code | Caller action | | --- | --- | --- | | 400 | `VALIDATION` | Correct query parameters, upload metadata, file, or idempotency key before retrying. | | 401 | `UNAUTHENTICATED` | Check the bearer header, expiry, revocation, and issuer/organization eligibility. Correct or replace the credential. | | 403 | `FORBIDDEN` | Obtain a credential with the required scopes. | | 404 | `NOT_FOUND` | The ID has no visible eligible resource. Missing and inaccessible resources return the same result. | | 409 | `CONFLICT` | Inspect `error.details.reason`; automatically retry only `UPLOAD_IN_PROGRESS`, honoring `Retry-After` with the same key and payload. All other, absent or unknown reasons require caller action. | | 413 | `PAYLOAD_TOO_LARGE` | Reduce the file or complete multipart body to the documented limits. | | 429 | `RATE_LIMITED` | Wait for the number of seconds in `Retry-After` before retrying. | | 503 | `SERVICE_UNAVAILABLE` | Wait for `Retry-After` before retrying the temporarily unavailable service. | | 500 | `INTERNAL` | Retry a bounded number of times with increasing delays; report persistent failures. | Separate read and write limits apply to the caller's network address and token. Use bounded retries with backoff and jitter for transient failures, honoring `Retry-After` as the minimum delay when present. Preserve the same page or ID when retrying; only advance pagination after a successful response. Stop after the retry budget and surface the failure. Repeated 400, 401, 403, 404, or 413 responses require caller action rather than an automatic retry loop. For a guided first read, searchable endpoint navigation, and client setup, visit the [Resguarda Developer Hub](/developers).