# Create a subscription

`POST /api/v1/subscriptions`

Needs the `subscriptions:write` scope, or a full-access key.

## Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | string | optional | A unique value for this operation, chosen by you. A retry with the same key and the same body returns the first response instead of running again. The same key with a different body answers 409 `idempotency_key_reused`; a key whose first request is still running answers 409 `idempotency_in_progress`. |

## Request body

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "customer_id": {
      "type": "string",
      "format": "uuid",
      "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "description": "Exactly one of `customer_id` / `customer_external_id`."
    },
    "customer_external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Your own customer id."
    },
    "plan_id": {
      "type": "string",
      "format": "uuid",
      "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "description": "The base plan: at most one of `plan_id` / `plan_code`. Optional when `items` is given: the first item becomes the base."
    },
    "plan_code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "A plan code; its latest active version is used.",
      "example": "gos_growth_annual"
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "plan_id": {
            "type": "string",
            "format": "uuid",
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          },
          "plan_code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "A plan code; its latest active version is used.",
            "example": "gos_growth_annual"
          },
          "quantity": {
            "anyOf": [
              {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              {
                "type": "string",
                "pattern": "^[1-9]\\d*$"
              }
            ]
          }
        }
      },
      "maxItems": 20,
      "description": "Extra charges beside the base plan, each `plan_id` or `plan_code`. Same interval as the base."
    },
    "quantity": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        {
          "type": "string",
          "pattern": "^[1-9]\\d*$"
        }
      ],
      "description": "Seats on the base plan. Default 1."
    },
    "start_at": {
      "type": "string",
      "format": "date-time"
    },
    "trial_end": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Omitted = the product's trial_days; null = no trial."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 500
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "Flat scalars: at most 50 keys of at most 40 characters; strings at most 500 characters.",
      "example": {
        "single_module_key": "crm"
      }
    }
  }
}
```

## Responses

### 201

Subscription created; an advance first invoice is finalized and charged against the default card.

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "status": {
          "type": "string"
        },
        "quantity": {
          "type": "integer"
        },
        "current_period_start": {
          "type": "string",
          "format": "date-time"
        },
        "current_period_end": {
          "type": "string",
          "format": "date-time"
        },
        "latest_invoice": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "id": {
              "type": "string",
              "format": "uuid",
              "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
            },
            "status": {
              "type": "string"
            },
            "total_cents": {
              "type": "string",
              "pattern": "^\\d+$",
              "description": "Invoice total.",
              "example": "1999"
            },
            "amount_due_cents": {
              "type": "string",
              "pattern": "^\\d+$",
              "description": "After credit.",
              "example": "1999"
            },
            "payment": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "attempted",
                    "skipped",
                    "failed"
                  ]
                },
                "payment_intent_id": {
                  "type": "string",
                  "description": "When attempted; settlement arrives by webhook."
                },
                "reason": {
                  "type": "string",
                  "description": "Why it was skipped or failed; the invoice stays open."
                }
              },
              "required": [
                "status"
              ],
              "description": "What happened when the invoice was charged against the default card after commit."
            }
          },
          "required": [
            "id",
            "status",
            "total_cents",
            "amount_due_cents",
            "payment"
          ]
        }
      },
      "required": [
        "id",
        "status",
        "quantity",
        "current_period_start",
        "current_period_end",
        "latest_invoice"
      ]
    },
    "_agent": {
      "type": "object",
      "properties": {
        "summary": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "ok"
          ]
        },
        "next_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "summary",
        "status",
        "next_actions",
        "warnings"
      ]
    },
    "api_version": {
      "type": "string",
      "example": "2026-07-01"
    }
  },
  "required": [
    "data",
    "_agent",
    "api_version"
  ]
}
```

### 404

Unknown `plan_code` (or `plan_id`), or unknown `customer_external_id`.

### 422

Validation failed, e.g. both `plan_id` and `plan_code` (give exactly one).
