Create an enrollment

POST/users/{user_id}/enrollments

Grants the user access to a delivery. The Idempotency-Key header is required.

If the user already has an enrollment for the same delivery, the existing enrollment is reactivated and returned with 200 OK instead of creating a new one.

The credentials must have access to every product included in the delivery. A delivery that does not exist, is archived, has no products, or includes products outside the scope of the current credentials is rejected with a validation error on delivery_id.

AuthorizationBearer <token>

Autonomous mode: the API credential secret, sent as a bearer token. Credential secrets are identified by a fixed prefix.

In: header

Path Parameters

user_id*string

Header Parameters

Idempotency-Key*string

Client-generated key that makes the request safe to retry. Must be 1 to 128 characters from [A-Za-z0-9._:-]. Required by this operation: a missing key returns idempotency_key_required, and a malformed key returns idempotency_key_invalid. Repeating the request with the same key and the same body returns the stored result with Idempotent-Replayed: true.

X-Client-Request-Id?string

Optional client-generated identifier of the request, up to 64 characters from [A-Za-z0-9._-]. Echoed back in the response and recorded in the request log; it never replaces the server-generated X-Request-Id.

Lengthlength <= 64

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/users/string/enrollments" \  -H "Idempotency-Key: string" \  -H "Content-Type: application/json" \  -d '{    "delivery_id": "string"  }'
{  "data": {    "created_at": "2019-08-24T14:15:22Z",    "deleted": true,    "delivery_id": "string",    "ends_at": "2019-08-24T14:15:22Z",    "id": "string",    "object": "enrollment",    "origin": {      "kind": "manual",      "sale_id": "string",      "subscription_id": "string"    },    "product_ids": [      "string"    ],    "revision": "string",    "status": "active",    "subscription_ends_at": "2019-08-24T14:15:22Z",    "updated_at": "2019-08-24T14:15:22Z",    "user_id": "string"  }}