FileRelay
Documentation
Try our Sandbox

Documents API

API endpoints for listing, retrieving, and retrying documents in FileRelay.

Documents API

The Documents API lets you query documents that have been received by FileRelay, inspect their delivery status, and retry failed deliveries.

List Documents

Retrieve a paginated list of documents in the current workspace.

GET /api/{workspaceSlug}/documents

Query Parameters

Parameter Type Description Default
page integer Page number 1
per_page integer Items per page (max 100) 25
repo_id string Filter by source repository ID --
status string Filter by status: pending, delivered, failed, retrying --
date_from string Filter documents received on or after (ISO 8601) --
date_to string Filter documents received on or before (ISO 8601) --

Example Request

curl -X GET "https://filerelay.dev/api/acme/production/documents?repo_id=Z1&status=delivered&per_page=10" \
  -H "Authorization: Bearer fr_live_abc123def456" \
  -H "Accept: application/json"

Example Response

{
  "data": [
    {
      "id": "doc_a1b2c3d4",
      "type": "document",
      "attributes": {
        "doc_id": "4A3F8B2C1D7E9F0A",
        "repo_id": "Z1",
        "comp_id": "data",
        "content_type": "application/pdf",
        "size_bytes": 245780,
        "status": "delivered",
        "received_at": "2026-04-04T10:30:00Z",
        "deliveries": [
          {
            "destination_id": "dest_s3prod",
            "destination_name": "S3 Production Archive",
            "status": "delivered",
            "delivered_at": "2026-04-04T10:30:02Z",
            "attempts": 1
          },
          {
            "destination_id": "dest_sharepoint",
            "destination_name": "SharePoint Team Site",
            "status": "delivered",
            "delivered_at": "2026-04-04T10:30:03Z",
            "attempts": 1
          }
        ]
      }
    },
    {
      "id": "doc_e5f6g7h8",
      "type": "document",
      "attributes": {
        "doc_id": "7B2E9C4D5F1A3E8B",
        "repo_id": "Z1",
        "comp_id": "data",
        "content_type": "image/tiff",
        "size_bytes": 1024000,
        "status": "delivered",
        "received_at": "2026-04-04T10:28:15Z",
        "deliveries": [
          {
            "destination_id": "dest_s3prod",
            "destination_name": "S3 Production Archive",
            "status": "delivered",
            "delivered_at": "2026-04-04T10:28:17Z",
            "attempts": 1
          }
        ]
      }
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "total": 247
  }
}

Get a Single Document

Retrieve details for a specific document by its FileRelay ID.

GET /api/{workspaceSlug}/documents/:id

Example Request

curl -X GET "https://filerelay.dev/api/acme/production/documents/doc_a1b2c3d4" \
  -H "Authorization: Bearer fr_live_abc123def456" \
  -H "Accept: application/json"

Example Response

{
  "data": {
    "id": "doc_a1b2c3d4",
    "type": "document",
    "attributes": {
      "doc_id": "4A3F8B2C1D7E9F0A",
      "repo_id": "Z1",
      "comp_id": "data",
      "content_type": "application/pdf",
      "size_bytes": 245780,
      "file_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
      "status": "delivered",
      "received_at": "2026-04-04T10:30:00Z",
      "metadata": {
        "sap_object_type": "BKPF",
        "sap_object_id": "1000012345672026",
        "ar_object": "ZCUSTOMINV"
      },
      "deliveries": [
        {
          "destination_id": "dest_s3prod",
          "destination_name": "S3 Production Archive",
          "status": "delivered",
          "delivered_at": "2026-04-04T10:30:02Z",
          "attempts": 1,
          "path": "/2026/04/04/4A3F8B2C1D7E9F0A.pdf"
        },
        {
          "destination_id": "dest_sharepoint",
          "destination_name": "SharePoint Team Site",
          "status": "delivered",
          "delivered_at": "2026-04-04T10:30:03Z",
          "attempts": 1,
          "path": "/Z1/invoice_4A3F8B2C1D7E9F0A.pdf"
        }
      ]
    }
  }
}

Stream Document Content

Stream the document bytes inline: the shared buffer copy first, then the flagged content-server copy. Strict destinations verify the stored copy against the archived SHA-256 (mismatches fail); latest destinations serve whatever is currently stored — check X-Content-Verified. Unlike the other endpoints this returns binary bytes, not the JSON envelope. Requires the content server to be enabled and the document to have a retrievable copy, otherwise 404.

GET /api/{workspaceSlug}/documents/:id/content

Example Request

curl -X GET "https://filerelay.dev/api/acme/production/documents/doc_a1b2c3d4/content" \
  -H "Authorization: Bearer [REDACTED]" -o invoice.pdf -D -

Response Headers

Header Meaning
Content-Type The document MIME type
Content-Disposition inline; filename="..."
X-Content-Source buffer, or destination:<name> for the copy served
X-Content-Verified true when the bytes match the archived copy, false for latest-mode serves

Mint a Document Signed URL

Mint a short-lived download URL for the document's newest signable copy, without proxying the bytes through FileRelay. It is a GET (minting changes no server state) with Cache-Control: no-store — whoever holds the URL can download, so expiries are clamped to 60–3600 seconds (default 1800, i.e. 30 minutes). Signing never downloads the bytes: by default a metadata (HEAD) check compares the object's stamped filerelay_sha256/ETag against the archived baseline, so a strict destination refuses to sign a copy known to have changed and latest signs anyway; pass verify=0 to skip that HEAD check. verified is true only when the stamped metadata hash matches, reported alongside verification (head_metadata | head_etag | head_drifted | unverified | unsupported) and retrieval_mode.

Signing ability is stricter than read ability: S3-family always signs; Azure Blob signs with the account Shared Key, or — with no Shared Key — mints a user-delegation SAS from the Entra identity (needs the Storage Blob Delegator role); GCS needs the service-account key. Types that cannot sign (SharePoint, SAS-token Azure, HMAC-only GCS) return 200 with url: null and verification: unsupported — use the content endpoint for those.

Standard ArchiveLink reads expect bytes, not URLs — SAP consumes these URLs through custom ABAP/RFC, not through the content-server protocol. The SAP user's network must be able to reach the resulting storage URL (or stream through Stream Document Content instead). The document page offers the same URL through its copy button (web session auth, same rules).

GET /api/{workspaceSlug}/documents/:id/signed-url?expires_in=600&verify=1

The :id route takes FileRelay's internal document ID. SAP clients know the content-repository id and the ArchiveLink document id instead — use the explicit lookup, which takes those two and never accepts an internal ID (keeping :id unambiguous):

GET /api/{workspaceSlug}/repositories/{repoId}/documents/by-doc-id/{arcDocId}/signed-url?expires_in=600&verify=1
curl "https://filerelay.dev/api/acme/production/repositories/Z1/documents/by-doc-id/4A3F8B2C1D7E9F0A/signed-url" \
  -H "Authorization: Bearer [REDACTED]"

For a CMIS Repository (cmis-server), {arcDocId} is SAP's KPro / ArchiveLink document id. FileRelay keys those documents by their CMIS object id, so the lookup resolves SAP's id through the object's sapbo:basedocument:Document property, which SAP sets on every document it stores.

The Fiori table and details modal call this through the SAP backend, so the FileRelay bearer token never reaches the browser. Response shape is identical to the :id route.

Example Request

curl "https://filerelay.dev/api/acme/production/documents/doc_a1b2c3d4/signed-url?expires_in=600" \
  -H "Authorization: Bearer [REDACTED]"

Example Response

{
  "data": {
    "id": "doc_a1b2c3d4",
    "type": "document-signed-url",
    "attributes": {
      "document_id": "4A3F8B2C1D7E9F0A",
      "url": "https://myaccount.blob.core.windows.net/sap-archive/invoices/DOC-12345.pdf?sv=...",
      "method": "GET",
      "expires_in": 600,
      "expires_at": "2026-10-19T12:05:00Z",
      "destination": "Azure Production Blobs",
      "verified": true
    }
  }
}

Verify Retrieval Copies

Queue an on-demand drift check (HEAD/hash probe) for every flagged retrieval copy of a document — the API equivalent of the document page's Verify destination copies button. Returns 202 with the number of probes queued; results arrive asynchronously as destination changes, not in this response. 404 when the document has no retrievable copy.

POST /api/{workspaceSlug}/documents/:id/verify-retrieval

Example Response

{
  "data": {
    "id": "doc_a1b2c3d4",
    "type": "document-verify-retrieval",
    "attributes": {
      "document_id": "4A3F8B2C1D7E9F0A",
      "probes_queued": 1
    }
  }
}

Retry a Failed Document

Retry delivery for a stuck or failed document. Terminally-failed deliveries are re-opened to pending (a fresh episode — stall strikes reset), then every pending row where nothing is actively working is re-queued. Rows already being worked are left alone, so retrying twice is safe.

POST /api/{workspaceSlug}/documents/:id/retry

Example Request

curl -X POST "https://filerelay.dev/api/acme/production/documents/doc_x9y8z7w6/retry" \
  -H "Authorization: Bearer fr_live_abc123def456" \
  -H "Accept: application/json"

Example Response

{
  "data": {
    "id": "doc_x9y8z7w6",
    "type": "document",
    "attributes": {
      "doc_id": "9C1D3E5F7A2B4D6E",
      "repo_id": "Z1",
      "status": "retrying",
      "received_at": "2026-04-03T15:42:00Z",
      "deliveries": [
        {
          "destination_id": "dest_s3prod",
          "destination_name": "S3 Production Archive",
          "status": "delivered",
          "delivered_at": "2026-04-03T15:42:02Z",
          "attempts": 1
        },
        {
          "destination_id": "dest_sharepoint",
          "destination_name": "SharePoint Team Site",
          "status": "retrying",
          "delivered_at": null,
          "attempts": 6
        }
      ]
    }
  }
}

Notes

  • Only documents with a failed status at one or more destinations can be retried
  • Retrying a document does not re-deliver to destinations that already succeeded
  • The retry follows the workspace retry settings (max retries, TTL)
  • Requires Member or Admin API key permissions

Document Statuses

Status Description
pending Document received, delivery not yet started
delivered All destinations received the document successfully
retrying At least one destination is being retried
failed At least one destination failed after all retry attempts
discarded No destination is wired to the source — the document was acknowledged to SAP but not retained or forwarded

Next Steps