---
title: "Create team subscription"
method: POST
path: "/api/v3/teams/{team_id}/subscriptions"
tags: ["Billing"]
---

# Create team subscription

`POST /api/v3/teams/{team_id}/subscriptions`

## Request

- Base URL: `https://codemagic.io`
- URL: `https://codemagic.io/api/v3/teams/{team_id}/subscriptions`
- Auth: API key in header `x-auth-token`
- TypeScript: <https://skmtc.dev/codemagic/apis/codemagic-api/docs/api/v3/teams/:team_id/subscriptions/post.ts> (a function with typed inputs; its response is checked against the schema)

## Path parameters

- `team_id` string, required

## Request body

- CreateSubscriptionSchema
  - `category` 'cicd' | 'codepush', required: The product line a subscription belongs to.
  - `pricing_model` 'flat_rate' | 'usage_based', required
  - `interval` 'monthly' | 'annual', required: How often a subscription is billed.
  - `items` CreateSubscriptionItemSchema[], required
    - `product_slug` 'cicd' | 'codepush', required: A product that can be added to a subscription.
  - `card` CreateSubscriptionCardSchema, required
    - `provider_id` string, required
  - `idempotency_key` string, nullable: Client key for this payment attempt. Reuse the same key on timeout and 5xx. Mint a new key on 400 and 422 client errors: card or promotion-code decline. On 409, re-read the team's subscriptions before retrying: an earlier attempt with this key may already have created one.
  - `code` string, nullable

## Response `201`

Document created, URL follows

- SubscriptionDetailsSchemaNoPagination
  - `data` SubscriptionDetailsSchema, required
    - `id` unknown, required
    - `pricing_model` 'flat_rate' | 'usage_based' | 'custom', required: How a subscription is priced: a fixed fee, metered usage, or a custom agreement.
    - `status` 'disabled' | 'active' | 'incomplete' | 'incomplete_expired' | 'unpaid' | 'paused' | 'past_due' | 'trialing' | 'canceled', required: State of a subscription. `disabled` means it was turned off; the rest follow Stripe's subscription statuses.
    - `category` 'cicd' | 'codepush', required: The product line a subscription belongs to.
    - `trial_end_at` string, date-time, nullable, required
    - `default_payment_method` PaymentMethodSchema, required
      - `type` 'card', required: Kind of payment method.
      - `provider_id` string, required
    - `provider_id` string, nullable, required
    - `provider_status` 'disabled' | 'active' | 'incomplete' | 'incomplete_expired' | 'unpaid' | 'paused' | 'past_due' | 'trialing' | 'canceled', required: State of a subscription. `disabled` means it was turned off; the rest follow Stripe's subscription statuses.
    - `created_at` string, date-time, required
    - `current_period_start_at` string, date-time, nullable, required
    - `current_period_end_at` string, date-time, nullable, required
    - `trial_start_at` string, date-time, nullable, required
    - `items` SubscriptionItemSchema[], nullable, required
      - `provider_id` string, required
      - `created_at` string, date-time, required
    - `sca_secret` string, nullable, required: Client secret the frontend passes to Stripe.js to run the 3DS/SCA challenge that authorises the subscription's first payment. Set while the cardholder still has to verify that payment, null otherwise.

## Other responses

- `400`: The request could not be validated
- `401`: Authentication is missing or invalid
- `403`: The caller lacks the required permission
- `404`: The requested resource does not exist
- `409`: Idempotency key was already used with different parameters, or already created a subscription that is no longer active
- `422`: Billing is not configured for the team
- `429`: The rate limit has been exceeded

---

[API](https://skmtc.dev/codemagic/apis/codemagic-api.md) - [All operations](https://skmtc.dev/codemagic/apis/codemagic-api/llms.txt) - [OpenAPI document](https://skmtc.dev/codemagic/apis/codemagic-api/revisions/be09630f65e2?raw)
