> For the complete documentation index, see [llms.txt](https://docs.vbase.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vbase.com/rest-api/rest-api-user-guide.md). Agents can also search and read this documentation through its [MCP server](https://docs.vbase.com/~gitbook/mcp).

# Guide

## About the REST API

The REST API provides a programmatic interface to interact with our services, allowing you to stamp files, inline data, or existing CIDs. This API is designed to be flexible and secure, supporting various data formats and authentication methods.

## One Blockchain Write at a Time per User

**Finish one blockchain write before starting another for the same user.** The rule applies across collections and clients:

| Blockchain write             | POST path                                                     |
| ---------------------------- | ------------------------------------------------------------- |
| Stamp creation               | `/api/v1/stamps` or deprecated `/api/v1/stamp/`               |
| On-chain collection creation | `/api/v1/collections` when it creates a blockchain collection |

Uploads of already-stamped files (`POST /api/v1/stamps/upload-stamped-file`) and reads may run concurrently, including during a blockchain write. This includes `POST /api/v1/stamps/verify` and `POST /api/v1/collections/verify`. The blockchain effect determines the rule, not the HTTP method. Different users can submit blockchain writes concurrently.

**Warning:** Overlapping blockchain writes can create duplicate commitments or fail on blockchain nonce conflicts.

### Current Stamp Creation Guard

When the stamp creation guard is enabled, it checks a lease for stamp creation. Collection creation does not acquire that lease; clients must coordinate its blockchain writes with stamp creation.

| Status | `error_code`                  | Meaning                                                                          |
| ------ | ----------------------------- | -------------------------------------------------------------------------------- |
| 409    | `stamp_in_progress`           | An unexpired lease is held. This request creates no stamp job or external write. |
| 503    | `operation_guard_unavailable` | The guard cannot coordinate this stamp request.                                  |

These responses include `Retry-After`, in seconds. An expired lease can admit a new request while the original operation continues. Neither this delay nor lease expiry proves completion. Clients must confirm completion even when the guard is disabled. A legacy `stamp_reconciliation_required` response requires checking the original outcome. The current guard does not emit it because a lease expired.

### Stamp Creation Retry Procedure

1. Send the first stamp request with `idempotent=true`.
2. Wait for the response.
3. If `Retry-After` is present, wait for its delay.
4. After an uncertain response, establish that the original operation has ended.
5. Resolve the original outcome using the checks below.
6. Retry the same stamp request only after completion and outcome resolution.
7. Start another blockchain write only after completion and outcome resolution.

A timeout, connection loss or HTTP 5xx can leave the outcome uncertain. `idempotent=true` checks indexed receipts; it does not exclude an active request. If completion or outcome remains unknown, contact support before another blockchain write. These prerequisites apply with or without the guard. Keep the content, collection, storage options and `idempotency_window` unchanged on a retry. **Warning:** A matching stamp outside the window can permit another commitment.

### Result Checks

| Check                                               | What it establishes                                      |
| --------------------------------------------------- | -------------------------------------------------------- |
| Find the matching `commitment_receipt`.             | The stamp exists. It does not confirm file availability. |
| If storage is required, download the expected file. | A successful download confirms file availability.        |
| Find the expected collection.                       | The collection exists.                                   |

These checks do not establish that the original request has stopped. An absent result does not prove failure. A stamp creation replay returns HTTP 200 with `commitment_receipt` only. It omits `file_object` and does not repair file storage. Collection creation and existing-stamp upload do not accept the stamp endpoint's idempotency fields. For file recovery, use [Upload Stamped File](#upload-stamped-file).

## Getting Started with the REST API

To begin using the REST API, you need to have a valid API token for authentication. The API is accessible via standard HTTP methods and returns JSON responses.

### How to Obtain an API Key

1. **Log in** to your vBase account at <https://app.vbase.com>
2. In your User Profile, navigate to ["Account Settings"](https://app.vbase.com/profile#account_settings)
3. Copy the API key from this screen and store it securely

### Base URL

```
https://app.vbase.com/api/v1/
```

## About the OpenAPI Description for the REST API

The REST API description uses OpenAPI 3.1.0. It describes endpoint request formats, mutually exclusive inputs, response fields, and nullable values for API clients and SDK generators. Swagger UI provides an interactive interface for exploring and testing API calls.

Access the Swagger UI at:

```
https://app.vbase.com/swagger/
```

For programmatic clients (agents, SDKs), fetch the OpenAPI 3.1 JSON at:

```
https://app.vbase.com/swagger.json
```

The Swagger UI route also supports:

```
https://app.vbase.com/swagger/?format=openapi
```

These schema URLs remain available without authentication. The URL `swagger.json` is retained for compatibility; the document identifies itself with `"openapi": "3.1.0"`. ReDoc is available at [app.vbase.com/redoc/](https://app.vbase.com/redoc/).

## Authenticating to the REST API

Protected API operations require your API key in the `Authorization` header. The OpenAPI description identifies which operations require authentication; the public `/api/v1/stamps/certificate` operation permits anonymous downloads. The `/api/v1/stamps/certificate/created` operation requires authentication and also accepts an authenticated session with CSRF protection. Use this header format for protected operations:

```
Authorization: Bearer <your-api-token>
```

The token is your opaque vBase API key, not a JWT. In Swagger UI's Authorize dialog, enter the API key itself; the HTTP bearer scheme adds the `Bearer` prefix to the request header.

Before running the curl examples, [obtain an API key](#how-to-obtain-an-api-key) and set `VBASE_API_KEY` as shown in [Examples](https://docs.vbase.com/rest-api/rest-api-user-examples.md).

## curl Command Conventions

These examples use Bash quoting. When quoting a static value, put single quotes around the complete argument, such as `--form-string 'data_cid=0x...'`. Simple tokens such as `POST` and URLs without shell-special characters can remain unquoted. Use double quotes when an argument needs shell variable expansion, such as `-H "Authorization: Bearer $VBASE_API_KEY"`. Do not add quotes around the value after `=`: those quotes would become part of the value sent to the API.

For multipart requests, use `--form-string 'name=value'` for text fields (including CIDs, data, names, booleans, and numbers) and `-F 'file=@path'` for file uploads. In `--form-string 'data={"status":"approved"}'`, the double quotes belong to the JSON value. Bash `$'...'` quoting is used only when escape sequences, such as newlines in a CSV body, are needed. See the [curl form options](https://curl.se/docs/manpage.html#--form-string) and [Bash quoting rules](https://www.gnu.org/software/bash/manual/html_node/Quoting.html).

## Request Body Formats

Swagger UI offers a request content-type selector for JSON, multipart, and URL-encoded stamp creation and file-upload requests. Choose `application/json` for inline data or a CID, and `multipart/form-data` to upload a file. The downloadable schema is OpenAPI 3.1.0; it uses full `/api/v1` paths, `components`, and response `content`.

`POST /v1/stamps` and `POST /v1/stamps/upload-stamped-file` accept either form fields (`multipart/form-data` or `application/x-www-form-urlencoded`) or a JSON object with `Content-Type: application/json`. Both formats use the same field names. File uploads require `multipart/form-data`; in JSON, send inline content as the string field `data`. Arrays and objects are not accepted as field values.

`POST /v1/collections` also accepts a JSON object, URL-encoded form fields, or multipart form fields with the same collection field names.

## Commitment Receipt Fields

Commitment receipts use `set_cid` for the blockchain set containing the stamped object (the SDK field is `setCid`). For a collection-associated stamp, this is the collection's CID, stored internally as `UserCollection.set_cid`. Collection objects expose that same identifier as `cid`, and API requests select a collection with `collection_cid`. Receipts retain `set_cid`; they do not duplicate it as `collection_cid`.

## Paginating Collections

`GET /api/v1/collections` returns one page of collections as a JSON array. **Change:** this endpoint previously returned every collection. It now returns at most `limit` items, so clients with more collections must follow `Link`. The page size `limit` has a default and a maximum; read them from the `default` and `maximum` of the `limit` parameter in the [OpenAPI description](#about-the-openapi-description-for-the-rest-api). `offset` is at least 0 and defaults to 0. Invalid `limit` or `offset` values return `400` with `{"error": "..."}`, where the message names the parameter. An `offset` at or past the total returns `200` with `[]`.

Every successful response includes an `X-Total-Count` header with the unpaged total, plus a `Link` header while more results remain. The next URL is a path from the server root, for example `</api/v1/collections?limit=100&offset=100>; rel="next"`. Prefix it with `https://app.vbase.com`, not the base URL. It keeps your other query parameters, so do not add them again. Follow the next link until it is absent to read the full list.

The optional `is_pinned` query parameter selects which collections are listed. Without it, the response lists the collections registered in your vBase account, newest first. `is_pinned=true` returns only pinned ones. `is_pinned=false` returns unpinned registered collections, followed by collections that exist on the blockchain but are not registered in your account; those come last, sorted by `cid`, with `id` and `created_at` set to `null`, and are included in `X-Total-Count`. If your account has no active blockchain address, `is_pinned=false` returns `404` with `{"error": "User address not found"}`.

Pages are computed per request, not from a snapshot. A collection created while you page can make an item appear twice; a deleted one can make you miss an item, and `X-Total-Count` can change between pages. De-duplicate by `cid`; for an exact list, restart if `X-Total-Count` changed.

```bash
curl -i 'https://app.vbase.com/api/v1/collections?limit=100' \
  -H "Authorization: Bearer $VBASE_API_KEY"
```

`-i` prints the response headers, including `X-Total-Count` and `Link`.

## Upload Size and Time Limits

Stamp creation and stamped-file upload accept files up to 10 MiB (10,485,760 bytes) by default. Deployments can configure `STAMP_MAX_UPLOAD_BYTES`. Oversized inputs return HTTP 413 with an `error` message before storage or blockchain work. The request body allows another 64 KiB for multipart framing and fields; other validation rules still apply. The same cap applies to files uploaded by the web stamper, even with storage disabled. To stamp a larger file without uploading its bytes, submit its content ID instead.

Inline `data`, sent as a JSON field or as a multipart form field, has the same limit as a file. Decoded inline data larger than that limit returns HTTP 413.

The hosted service has a 120-second total request deadline, including uploading the body. A slow request can time out even below the size limit. A timeout ends only the HTTP response; the service can continue and complete the operation after it. Treat a timeout, a lost connection or an HTTP 5xx as an unknown outcome.

After a network failure, the service, the blockchain indexer and the blockchain can each know something different about the request. No client or server procedure can fully reconcile them, and a retry can create a duplicate stamp. The steps below reduce that risk; they cannot remove it.

* **Stamp creation:** follow the [Stamp Creation Retry Procedure](#stamp-creation-retry-procedure). Send the first request with `idempotent=true`, and keep the content, collection, storage options and `idempotency_window` unchanged on any retry. Read the responses narrowly:

  * HTTP 409 `stamp_in_progress` shows only that an operation holds your account's stamp lease. It can be another request, or a lease left after the original finished. It does not show that your request is still running, and its absence does not show that it ended. Wait for `Retry-After`.
  * HTTP 200 with `commitment_receipt` returns the latest matching indexed receipt inside the window. That receipt can come from an earlier request for the same content rather than the one that timed out.
  * Elapsed time does not settle the outcome. A blockchain write can complete after the service stops working on it, and indexing can lag.

  Use the [result checks](#result-checks) to find what the original request produced. They cannot show that it ended, and the client has no way to establish that. While the outcome or termination remains unknown, contact support instead of submitting another stamp.
* **Stamped-file upload:** this endpoint does not accept idempotency fields and makes no blockchain write. Retry with the same content and collection as described in [Upload Stamped File](#upload-stamped-file). The service verifies saved files before it uploads again.

## Request Validation Rules

For endpoints that use strict request schemas, unknown or unrecognized request keys are rejected with `400 Bad Request`. Only documented request fields are accepted. The stamp endpoint also retains its existing camelCase aliases, such as `dataCid` and `storeStampedFile`; examples use snake\_case names.

For `POST /api/v1/stamps`, send a JSON object, multipart form, or URL-encoded form. File uploads require multipart. Select exactly one content source: a file, nonempty `data`, or `data_cid`. At most one nonempty collection selector, `collection_cid` or `collection_name`, is allowed. Empty optional text fields do not select another content source. If `data` contains JSON, send that JSON as a string in the form field or JSON body; `data` itself must remain a string. In multipart requests, an empty text `file` field is ignored and can accompany `data` or `data_cid`. An uploaded file with a name remains selected even if it has zero bytes, so it conflicts with another content source.

For stamp creation and stamped-file uploads, an original filename can have at most 230 characters (Unicode code points), including the extension. This applies to uploaded files and to `file_name` with inline `data`. The stamp routes apply NFKC normalization to `file_name` and check the limit again after it. A longer filename returns HTTP 400 before storage or blockchain calls; no stamp is created and no file is stored. A stored file gains a timestamp before the extension, for example `report_2025-01-01_12-00-00+0000.pdf`; accepted names are never shortened.

Stamp idempotency is disabled unless `idempotent=true` is supplied. Storage is enabled when `store_stamped_file=true` is supplied or when the account stores stamped files, which is the default for new accounts. An idempotent replay returns HTTP 200; a new stamp returns HTTP 201. The creation response contains `file_object: null` when no stamped file was stored. If final storage succeeds, `file_object` contains the final `file_name` and `file_path`.

## Keeping your API credentials secure

* Never share your API token publicly
* Store your API token securely
* Use environment variables to store your API token
* Never commit API tokens to version control

## API Endpoints

### Account Stamp Credits

`GET /api/v1/billing/credits` returns the authenticated account's stored stamp balance and plan. Use the same bearer API key as other protected endpoints:

```bash
curl https://app.vbase.com/api/v1/billing/credits \
  -H "Authorization: Bearer $VBASE_API_KEY"
```

Example response:

```json
{
  "subscription_plan": "free",
  "next_renewal_date": "2026-10-25",
  "free_stamp_credits": 0,
  "paid_stamp_credits": 200,
  "total_stamp_credits": 200
}
```

Free credits are the stored expiring credits; paid credits are non-expiring. The total is their sum, including any negative stored balance. Free plans use `"free"`; paid plans use their existing base-plan slug, excluding add-ons. The plan is null if no plan is available. The renewal date is a UTC date or null when unknown. An account without a balance row returns zero credits and a null renewal date.

Results are cached per account for 10 seconds and can lag spending, purchases, plan changes, or renewal by that amount. This request does not renew credits or create a balance. Spending checks use live balances. Credit balances are separate from request throughput quotas and rate-limit headers.

### Verify User Collection

**POST** `/v1/collections/verify`

This endpoint verifies a stamped collection against blockchain records for the authenticated user.

#### Request Format

Send a JSON object with `Content-Type: application/json`. CSV bodies and multipart uploads are no longer accepted by this API and return HTTP 415:

```json
{
  "error": "Unsupported Content-Type. Use application/json.",
  "timestamp": "2026-10-29T12:00:00Z"
}
```

To migrate, convert CSV rows to `objects` entries with `timestamp` (CSV `t`), `cid` (CSV `c`), and optional `file_name` (CSV `f`). Put optional collection identity fields at the top level and send the JSON body directly, rather than uploading a file. The Verify page continues to support CSV and ZIP input.

For JSON requests, top-level `collection_name` and `user_address` are optional. If they are omitted or set to `null`, the backend will try to infer collection metadata from the submitted records.

The `context` object is also optional and may be omitted or set to `null`. Each entry in `objects` may omit `file_name` or set it to `null`.

Use `Accept: application/json` for the response.

#### Example Requests

**JSON body:**

```bash
curl -X POST https://app.vbase.com/api/v1/collections/verify \
-H "Authorization: Bearer $VBASE_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
  "collection_name": "my-collection",
  "user_address": "0x123",
  "objects": [
    {
      "timestamp": "2024-01-01T00:00:00+00:00",
      "cid": "cid1",
      "file_name": "example.csv"
    }
  ]
}'
```

#### Example Response

Verification timestamps use ISO 8601 UTC with an explicit offset. Clients control timezone rendering; verification responses do not include `display_timezone`.

**Response (200):**

```json
{
  "collections": [
    {
      "name": "my-collection",
      "cid": "0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800",
      "user_address": "0x4A281DdC750359d5C0D2D51A890cefA43485EF2d",
      "matched_receipts": [
        {
          "transaction_hash": "0xbe3f57e7ad7b00e79f88b3f9ffc9fdee84d3251cfc2d121386d8fe793b0d782a",
          "user_address": "0x4A281DdC750359d5C0D2D51A890cefA43485EF2d",
          "set_cid": "0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800",
          "object_cid": "0x6f3328cba0ffde8429e66008708419751921bf41737e32a0fcd173849e325561",
          "timestamp": "2025-07-23T11:42:15+00:00",
          "chain_id": 8453
        }
      ],
      "unmatched_objects": [
        {
          "cid": "0xaeda4cf7d65f9d67b128bf795b5f237183550a814c9d4aa83c7e84f027d4aeec",
          "timestamp": "2025-07-23T20:34:58+00:00"
        }
      ],
      "unmatched_receipts": []
    }
  ]
}
```

Each entry in `collections` identifies the verified collection by:

* `name`: collection name
* `cid`: collection/set CID
* `user_address`: resolved owner address used for verification
* `matched_receipts`: blockchain receipts matched to submitted objects for this collection
* `unmatched_objects`: submitted objects with no matching blockchain receipt for this collection
* `unmatched_receipts`: blockchain receipts with no matching submitted object for this collection

### Upload Stamped File

**POST** `/v1/stamps/upload-stamped-file`

This endpoint allows you to upload a file or inline data that has been previously stamped and verified against blockchain records.

#### Overview

The upload stamped file endpoint calculates the object CID from the submitted file or inline data, verifies that matching blockchain commitments exist for the authenticated user and collection, uploads the content, and associates each uploaded file with its matching commitment.

Content must be provided as either `file` or `data`, but not both. `file_name` is required whenever `data` is provided.

If the same stamped content is uploaded again with a different file name, the endpoint is idempotent: it returns the existing file object with HTTP 200 and does not create another uploaded copy for the same commitment.

An upload that encounters an active claim on the same receipt returns HTTP 409 with `stamp_in_progress`. Scheduled recovery skips that receipt with `receipt_upload_busy`. Claim cleanup is best effort. A failed upload attempts to delete its claim on exit. If database cleanup fails, the claim remains until expiry; another attempt can then take over.

If multiple commitments in the collection match the same object CID, the first successful upload stores one timestamped file copy for each matching commitment. The API response contains one matching `commitment_receipt` and `file_object`.

#### Request Parameters

| Parameter        | Type   | Required    | Description                                                                                                                                 |
| ---------------- | ------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| collection\_name | String | No          | Collection name (case-insensitive, must not be empty). Provide this or `collection_cid`.                                                    |
| collection\_cid  | String | No          | Collection CID (hex hash). Provide this or `collection_name`.                                                                               |
| file             | File   | No          | Previously stamped file to upload. Provide this or `data`, but not both. Its name can have at most 230 characters, including the extension. |
| data             | String | No          | Inline text / JSON data to upload. Provide this or `file`, but not both.                                                                    |
| file\_name       | String | Conditional | Required when `data` is provided. Maximum 230 characters, including the extension.                                                          |

**Note**: User address is automatically determined from the authenticated user's profile, so no `user_address` parameter is needed. At least one of `collection_name` or `collection_cid` must be present, and exactly one of `file` or `data` must be present.

#### Validation Process

The endpoint performs the following validations in sequence:

1. **Input Validation**: Validates collection name is not empty, validates collection identifiers (`collection_name`/`collection_cid`), enforces exactly one content source (`file` xor `data`), requires `file_name` whenever `data` is provided, and rejects filenames longer than the [filename limit](#request-validation-rules).
2. **User Address Resolution**: Automatically determines user address from authenticated user's profile
3. **Collection Lookup**: Finds the collection by name or CID for the authenticated user
4. **CID Calculation**: Calculates object CID from the uploaded file, or from inline data when no file is provided
5. **Blockchain Verification**: Verifies that matching commitments exist in blockchain records for the user's address and collection
6. **File Association**: Uploads the file and associates it with each matching commitment that does not already have a file
7. **Idempotent Duplicate Handling**: Returns the existing file object with HTTP 200 when a matching commitment is already associated with a file

Unknown or unrecognized form or JSON fields are rejected with `400 Bad Request`.

#### Response Codes

| Status Code | Description                                         | When It Occurs                                                                                                                                                                                                                                                                                 |
| ----------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 200         | File already uploaded                               | Matching commitment already has an associated file; no duplicate copy is created                                                                                                                                                                                                               |
| 201         | File uploaded successfully                          | File passes all validations and uploads successfully for one or more matching commitments                                                                                                                                                                                                      |
| 400         | Invalid input or validation failed                  | Empty collection name, missing required parameters, or a filename longer than the [filename limit](#request-validation-rules)                                                                                                                                                                  |
| 404         | Collection not found or no blockchain records found | Collection doesn't exist or no matching blockchain records                                                                                                                                                                                                                                     |
| 409         | `stamp_in_progress`                                 | The receipt is busy, the upload lost its claim, or the file state changed during the upload.                                                                                                                                                                                                   |
| 413         | Stamp input too large                               | The upload exceeds the configured upload limit.                                                                                                                                                                                                                                                |
| 503         | `operation_guard_unavailable`                       | Receipt coordination is unavailable.                                                                                                                                                                                                                                                           |
| 500         | File processing, blockchain, or upload errors       | CID calculation fails, blockchain errors, or upload failures. Also returned when an earlier attempt reserved a file destination that current path rules reject; the stamp stays confirmed, no file is uploaded, and a retry returns the same error; contact support to repair the destination. |

HTTP 409 and 503 can both arrive after S3 has stored the file. If several receipts match, the service processes them in order and an error stops the request at that receipt, so earlier receipts may already be complete. Wait for the delay in `Retry-After`, then retry with the same content and collection. The service verifies saved destinations before issuing another PUT.

A retry reuses the filename that an earlier attempt reserved for the receipt in the same collection, so the stored filename can differ from the name you upload and can be longer than the [filename limit](#request-validation-rules) for new names.

#### Example Requests

**Successful Upload:**

```bash
curl -X POST https://app.vbase.com/api/v1/stamps/upload-stamped-file \
-H "Authorization: Bearer $VBASE_API_KEY" \
--form-string 'collection_name=My Collection' \
-F 'file=@stamped_file.pdf'
```

**Successful Upload Using Collection CID and Inline Data:**

```bash
curl -X POST https://app.vbase.com/api/v1/stamps/upload-stamped-file \
-H "Authorization: Bearer $VBASE_API_KEY" \
--form-string 'collection_cid=0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800' \
--form-string 'data={"status":"approved"}' \
--form-string 'file_name=stamped_data.json'
```

**Successful Upload Using a JSON Body:**

```bash
curl -X POST https://app.vbase.com/api/v1/stamps/upload-stamped-file \
-H "Authorization: Bearer $VBASE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"collection_cid": "0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800", "data": "{\"status\":\"approved\"}", "file_name": "stamped_data.json"}'
```

**Response (201):**

```json
{
  "commitment_receipt": {
    "transaction_hash": "0xbe3f57e7ad7b00e79f88b3f9ffc9fdee84d3251cfc2d121386d8fe793b0d782a",
    "user_address": "0x4A281DdC750359d5C0D2D51A890cefA43485EF2d",
    "set_cid": "0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800",
    "object_cid": "0xf2ad58a03e4d1e4cf11f046e32b0e12fb9d835f63fa79fd5a4769d24ea5b3949",
    "timestamp": "2025-01-01 12:00:00+00:00",
    "chain_id": 1
  },
  "file_object": {
    "file_name": "stamped_file_2025-01-01_12-00-00+0000.pdf",
    "file_path": "0x4A281DdC750359d5C0D2D51A890cefA43485EF2d/collections/My Collection/stamped/stamped_file_2025-01-01_12-00-00+0000.pdf"
  }
}
```

**Duplicate Upload Response (200):**

```json
{
  "commitment_receipt": {
    "transaction_hash": "0xbe3f57e7ad7b00e79f88b3f9ffc9fdee84d3251cfc2d121386d8fe793b0d782a",
    "user_address": "0x4A281DdC750359d5C0D2D51A890cefA43485EF2d",
    "set_cid": "0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800",
    "object_cid": "0xf2ad58a03e4d1e4cf11f046e32b0e12fb9d835f63fa79fd5a4769d24ea5b3949",
    "timestamp": "2025-01-01 12:00:00+00:00",
    "chain_id": 1
  },
  "file_object": {
    "file_name": "stamped_file_2025-01-01_12-00-00+0000.pdf",
    "file_path": "0x4A281DdC750359d5C0D2D51A890cefA43485EF2d/collections/My Collection/stamped/stamped_file_2025-01-01_12-00-00+0000.pdf"
  }
}
```

**Error Responses:**

**Collection Not Found (404):**

```json
{
  "error": "Collection not found"
}
```

**No Blockchain Records (404):**

```json
{
  "error": "No records found for this object_cid: 0x329c036f2bcedbb9c44521c22a84d82ae328fef03e942c42b447d4ae67bbd800"
}
```

If a matching blockchain receipt is verified but its local `UserStampedFiles` row is missing, the endpoint recreates that row with `success` stamp status and the authenticated user, object CID, collection CID, receipt timestamp, and full receipt. It then continues the upload and returns the normal `201` response. Repeating the request reuses the recovered row and stored file rather than creating a duplicate.

**File Processing Error (500):**

```json
{
  "error": "Failed to process file for object CID generation"
}
```

#### Error Handling

The API uses structured error responses with appropriate HTTP status codes to help you handle different error scenarios:

* **4xx Client Errors**: Issues with your request (missing parameters, invalid data, not found)
* **5xx Server Errors**: Internal processing issues (file processing, blockchain connectivity, upload failures)

Always check the HTTP status code first, then parse the error message for specific details about what went wrong.

#### Best Practices

1. **Validate Input**: Ensure collection names are not empty before sending requests
2. **Handle Errors**: Implement proper error handling for all status codes
3. **File Validation**: Only upload files that have been previously stamped
4. **Collection Management**: Ensure collections exist before attempting uploads
5. **Retry Logic**: Implement retry logic for 5xx errors (server issues)
6. **Rate Limiting**: Respect API rate limits to avoid throttling

## Verification and certificate request methods

`POST /api/v1/stamps/verify` accepts CID batches and an optional user filter. It requires authentication. It does not create stamps. Use one of these body formats:

* `application/json`
* `multipart/form-data`
* `application/x-www-form-urlencoded`

In JSON, send `cids` as an array. Send `filter_by_user` as a boolean. In forms, repeat the `cids` field for each CID. Send `filter_by_user` once. Use `true` or `false`. If the filter is omitted, it defaults to false. Repeated filter values and unknown fields return 400. Form boolean filtering extends the accepted inputs. Existing successful CID requests remain supported. Verification responses omit `display_timezone`. Verification timestamps use ISO 8601 UTC with an explicit `+00:00` offset.

Example URL-encoded body with two CIDs:

```
cids=0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&cids=0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb&filter_by_user=true
```

`POST /api/v1/collections/verify` accepts JSON only. Other media types return 415. Browser verification retains CSV and ZIP support. `POST /api/v1/stamps/certificate` accepts JSON receipt selectors. It reuses a matching current saved PDF when available. Otherwise, it generates a PDF in memory without saving it. These operations do not create stamps. Use the existing POST URLs. GET is not supported.

CID verification returns 400 for invalid input. It returns 500 for connection failures, unexpected service failures, or invalid service output. Service and model-validation failures use an `error` field.

Certificate download remains public. If the certificate contains characters unsupported by the bundled PDF fonts, both certificate endpoints return HTTP 422 with an `error` message. The stamp remains valid; contact support instead of retrying the same request. Rendering infrastructure failures return HTTP 503. Every certificate response uses `Cache-Control: no-store`, including failures. Do not cache a generated PDF or an error response. Changing the HTTP method alone would not enable caching under this policy.

The signed-in stamp creation page uses `POST /api/v1/stamps/certificate/created` with JSON receipt selectors. The `chain_id` field is optional on this authenticated route because the owner's saved receipt supplies it; the public certificate route still requires it. It renders the current user's successful saved stamp on demand, without waiting for public indexing or saving the PDF to S3. Session requests require CSRF.

## Saved certificate downloads

`POST /api/v1/stamps/certificate` validates the selected stamp, then loads a matching current certificate generated by the materialization command when its saved PDF is available. If no usable saved PDF exists, it generates the certificate on the fly without saving it. Downloads do not update certificate state or upload new PDFs.

Stored PDFs retain the display information and hash instructions from when they were generated; freshly rendered public PDFs use the current display information and neutral hash guidance. Anonymous access and `Cache-Control: no-store` remain unchanged.

Certificate generation is rate-limited; honor `Retry-After` on HTTP 429. Generation is limited per authenticated account or per anonymous client address in a rolling minute. Visitors whose requests reach the service from the same address, for example behind a shared proxy or NAT, share one allowance. Downloads of usable saved PDFs do not consume generation attempts. Authentication and CSRF requirements are described in the [OpenAPI documentation](#about-the-openapi-description-for-the-rest-api).
