# Create a delivery

`POST https://api.cademi.com.br/api/v3/sales/deliveries`

Operation ID: `deliveries.create` · API v3

Creates a delivery for a payment gateway from the gateway catalog. The selected gateway determines whether a secret is required.

The secret is write-only: responses indicate only whether a secret is configured.

Required permissions: `deliveries.create`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `external_ids` | array of string | no |  |
| `gateway` | string | yes |  |
| `kind` | string, one of `one_time`, `subscription` | no |  |
| `name` | string | yes |  |
| `products` | DeliveryProducts | no | The set of products that a delivery grants access to. |
| `schedules` | array of object | no |  |
| `secret` | string or null | no |  |
| `tags` | array of string | no |  |

## Responses

### 201

Returns the newly created 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.

### 409

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

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

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