# Update a delivery

`PATCH https://api.cademi.com.br/api/v3/sales/deliveries/{delivery_id}`

Operation ID: `deliveries.update` · API v3

Updates an existing delivery.

Changing `status` requires the `deliveries.archive` permission in addition to `deliveries.update`. Archiving a delivery stops it from processing new sales but does not revoke access from users who have already purchased.

To avoid overwriting a newer version, send the delivery's current `ETag` in the `If-Match` header.

Replicated deliveries are read-only; updating or archiving them returns `403` with the `replica_readonly` error code.

Required permissions: `deliveries.update`, `deliveries.archive`, `deliveries.archive`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `delivery_id` | path | string | yes |  |
| `If-Match` | header | string | no |  |

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `deleted` | boolean | no |  |
| `external_ids` | array of string | no |  |
| `hidden` | boolean | no |  |
| `name` | string | no |  |
| `secret` | string or null | no | Gateway secret for the delivery. Set to null to remove the secret; omit the field to keep the current value. |
| `status` | string, one of `active`, `archived` | no |  |

## Responses

### 200

Returns the updated delivery.

Body: `data`: Delivery.

Fields of Delivery:

| Field | Type | Required | Description |
|---|---|---|---|
| `created_at` | string (date-time) | yes |  |
| `enrollments_count` | integer | yes |  |
| `external_ids` | array of string | yes | Product codes on the payment gateway. Existing codes are never rewritten, because cancellations are matched to the delivery by these codes. |
| `gateway` | string | yes | Public ID of the payment gateway from the catalog, prefixed with gtw_. |
| `hidden` | boolean | yes |  |
| `id` | string | yes | Public ID of the delivery, prefixed with dlv_. |
| `kind` | string, one of `one_time`, `subscription` | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `delivery` | yes |  |
| `postback_url` | string | yes | URL that the payment gateway calls when a sale occurs. |
| `products_count` | integer | yes |  |
| `revision` | string | yes |  |
| `secret` | object | yes | The gateway secret is write-only. Responses only indicate whether it is configured. |
| `status` | string, one of `active`, `archived` | yes | Lifecycle status of the delivery. Archiving a delivery stops new sales through it; users who already purchased keep their access. |
| `tags_count` | integer | yes |  |
| `updated_at` | string (date-time) | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The delivery was not found or is not accessible with the current credentials.

Body: Error.

### 409

A gateway product code is already in use by another active delivery.

Body: Error.

### 412

The resource has changed since the supplied revision was retrieved.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
