> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yorlet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a subscription

> Create a subscription



## OpenAPI

````yaml openapi-billing.json POST /v1/subscriptions
openapi: 3.1.0
info:
  title: Yorlet Billing API
  description: APIs for managing invoices, coupons, credit grants, and subscription items.
  version: 1.0.0
servers:
  - url: https://api.yorlet.com
    description: Production
  - url: https://api.yorlet.io
    description: Sandbox
security: []
paths:
  /v1/subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create a subscription
      description: Create a subscription
      operationId: subscriptions_create
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                add_invoice_items:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      amount:
                        type: integer
                        description: >-
                          The amount to be charged, represented as a whole
                          integer if possible.
                      currency:
                        type: string
                        description: >-
                          Three-letter ISO currency code, in lowercase. Must be
                          a supported currency.
                      description:
                        type: string
                        description: >-
                          The description for the invoice item, to be displayed
                          to the customer.
                      metadata:
                        type:
                          - object
                          - 'null'
                        additionalProperties:
                          type: string
                        description: >-
                          Set of key-value pairs that you can attach to an
                          object. This can be useful for storing additional
                          information about the object in a structured format.
                      price:
                        type: string
                        description: The ID of the price object.
                      tax_percent:
                        type: number
                        minimum: 0
                        maximum: 100
                        description: >-
                          The tax percentage to use when calculating the tax
                          amount.
                      tax_rate:
                        type: string
                        description: The ID of the tax rate object.
                      transfer_behavior:
                        type: string
                        enum:
                          - automatic
                          - owner
                          - none
                        description: >-
                          The invoice item transfer behavior. The default is
                          automatic.
                      transfer_destination:
                        type: string
                        description: >-
                          ID of the owner that will be the transfer destination.
                          Only allowed when the invoice item transfer behavior
                          is owner.
                      type:
                        type: string
                        enum:
                          - charge
                          - rent
                          - product
                        description: The type of the invoice item.
                      unit:
                        type:
                          - string
                          - 'null'
                        description: The ID of the unit the invoice item is for.
                    required:
                      - amount
                      - currency
                      - description
                      - tax_percent
                      - transfer_behavior
                      - type
                  maxItems: 10
                  description: >-
                    A list of invoice items to add to invoices created by the
                    subscription.
                billing_anchor:
                  type:
                    - integer
                    - 'null'
                  description: The reference point that aligns future billing cycle dates.
                billing_anchor_config:
                  type:
                    - object
                    - 'null'
                  properties:
                    day_of_month:
                      type: integer
                      minimum: 1
                      maximum: 31
                      description: The day of the month to anchor billing to.
                  required:
                    - day_of_month
                  description: Configuration for the billing anchor.
                collection_method:
                  type: string
                  enum:
                    - charge_automatically
                    - send_invoice
                  description: The collection method for the subscription.
                coupon:
                  type:
                    - string
                    - 'null'
                  description: The identifier of the coupon to apply to the subscription.
                custom_fields:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        maxLength: 30
                        description: The name of the custom field.
                      value:
                        type: string
                        maxLength: 30
                        description: The value of the custom field.
                    required:
                      - name
                      - value
                  maxItems: 4
                  description: Custom fields attached to the subscription invoices.
                days_before_collection:
                  type: integer
                  minimum: 0
                  maximum: 7
                  description: >-
                    The number of days before the due date to attempt
                    collection.
                days_until_due:
                  type:
                    - integer
                    - 'null'
                  minimum: 0
                  description: The number of days until the invoice is due.
                default_payment_method:
                  type:
                    - string
                    - 'null'
                  description: >-
                    The identifier of the default payment method for the
                    subscription.
                description:
                  type: string
                  description: The description of the subscription.
                end_date:
                  type:
                    - integer
                    - 'null'
                  description: The end date of the subscription.
                end_date_config:
                  type:
                    - object
                    - 'null'
                  properties:
                    day:
                      type: integer
                      minimum: 1
                      maximum: 31
                      description: The day of the month for the end date.
                    month:
                      type: integer
                      minimum: 1
                      maximum: 12
                      description: The month for the end date.
                    year:
                      type: integer
                      description: The year for the end date.
                  required:
                    - day
                    - month
                    - year
                  description: Configuration to compute the end date of the subscription.
                metadata:
                  type:
                    - object
                    - 'null'
                  additionalProperties:
                    type: string
                  description: Set of key-value pairs to attach to the subscription.
                payment_settings:
                  type: object
                  properties:
                    payment_method_types:
                      type: array
                      items:
                        type: string
                        enum:
                          - autogiro
                          - bacs_debit
                          - card
                          - card_present
                          - bank_transfer
                          - direct_transfer
                          - gbp_credit_transfer
                          - pay_by_bank
                          - sepa_debit
                      minItems: 1
                      description: The payment method types allowed for the subscription.
                  required:
                    - payment_method_types
                  description: The payment settings for the subscription.
                phases:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      start_date:
                        type: integer
                        description: The start date of the phase.
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            description:
                              type: string
                              description: The description of the subscription item.
                            metadata:
                              type:
                                - object
                                - 'null'
                              additionalProperties:
                                type: string
                              description: >-
                                Set of key-value pairs to attach to the
                                subscription item.
                            price:
                              type: string
                              description: >-
                                The identifier of the price to use for the
                                subscription item.
                            price_data:
                              type: object
                              properties:
                                amount:
                                  type: integer
                                  description: The amount of the price.
                                currency:
                                  type: string
                                  description: The currency of the price.
                                tax_percent:
                                  type: number
                                  description: The tax percentage to apply to the price.
                              required:
                                - amount
                                - currency
                              description: The price data for the subscription item.
                            proration_behavior:
                              type: string
                              enum:
                                - create_prorations
                                - none
                              description: >-
                                Whether to create prorations when creating the
                                subscription item.
                            schedule:
                              type:
                                - array
                                - 'null'
                              items:
                                type: object
                                properties:
                                  amount:
                                    type: integer
                                    description: The amount for the scheduled change.
                                  effective_at:
                                    type: integer
                                    description: >-
                                      The date the scheduled change takes
                                      effect.
                                  effective_at_config:
                                    type: object
                                    properties:
                                      day:
                                        type: integer
                                        minimum: 1
                                        maximum: 31
                                        description: >-
                                          The day of the month the scheduled
                                          change takes effect.
                                      month:
                                        type: integer
                                        minimum: 1
                                        maximum: 12
                                        description: >-
                                          The month the scheduled change takes
                                          effect.
                                      year:
                                        type: integer
                                        description: >-
                                          The year the scheduled change takes
                                          effect.
                                    required:
                                      - day
                                      - month
                                      - year
                                    description: >-
                                      Configuration to compute the effective
                                      date of the scheduled change.
                                required:
                                  - amount
                              description: The schedule for the subscription item.
                            tax_rate:
                              type: string
                              description: >-
                                The identifier of the tax rate for the
                                subscription item.
                            transfer_behavior:
                              type: string
                              enum:
                                - automatic
                                - owner
                                - none
                              description: The transfer behavior for the subscription item.
                            transfer_destination:
                              type: string
                              description: >-
                                The identifier of the connected account to
                                transfer funds to.
                            type:
                              type: string
                              enum:
                                - charge
                                - rent
                                - product
                              description: The type of the subscription item.
                            unit:
                              type:
                                - string
                                - 'null'
                              description: >-
                                The identifier of the unit associated with the
                                subscription item.
                          required:
                            - price_data
                            - type
                        minItems: 1
                        maxItems: 10
                        description: The items in the phase.
                    required:
                      - start_date
                      - items
                  minItems: 1
                  description: >-
                    The phases of the subscription. Required when interval is
                    custom.
                start_date:
                  type:
                    - integer
                    - 'null'
                  description: The start date of the subscription.
                start_date_config:
                  type:
                    - object
                    - 'null'
                  properties:
                    day:
                      type: integer
                      minimum: 1
                      maximum: 31
                      description: The day of the month for the start date.
                    month:
                      type: integer
                      minimum: 1
                      maximum: 12
                      description: The month for the start date.
                    year:
                      type: integer
                      description: The year for the start date.
                  required:
                    - day
                    - month
                    - year
                  description: Configuration to compute the start date of the subscription.
                application:
                  type:
                    - string
                    - 'null'
                  description: >-
                    The identifier of the application to associate with the
                    subscription.
                currency:
                  type: string
                  enum:
                    - gbp
                    - usd
                    - eur
                    - sek
                  description: >-
                    The currency of the subscription. Required when application
                    is not provided.
                  example: gbp
                customer:
                  type: string
                  description: >-
                    The identifier of the customer to create the subscription
                    for.
                first_invoice_creation:
                  type:
                    - string
                    - 'null'
                  enum:
                    - immediately
                    - null
                  description: Whether to create the first invoice immediately.
                from_subscription:
                  type: object
                  properties:
                    action:
                      type: string
                      enum:
                        - revision
                      description: The action to perform on the source subscription.
                    subscription:
                      type: string
                      description: The identifier of the source subscription.
                  required:
                    - action
                    - subscription
                  description: >-
                    Create the subscription as a revision of an existing
                    subscription.
                interval:
                  type: string
                  enum:
                    - month
                    - week
                    - custom
                  description: The billing interval for the subscription.
                interval_count:
                  type: integer
                  description: >-
                    The number of intervals between each billing cycle. Required
                    when interval is not custom.
                invoice_settings:
                  type: object
                  properties:
                    custom_fields:
                      type:
                        - array
                        - 'null'
                      items:
                        type: object
                        properties:
                          name:
                            type: string
                            maxLength: 40
                            description: The name of the custom field.
                          value:
                            type: string
                            maxLength: 140
                            description: The value of the custom field.
                        required:
                          - name
                          - value
                      maxItems: 4
                      description: Custom fields to include on invoices.
                  description: The invoice settings for the subscription.
                items:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      description:
                        type: string
                        description: The description of the subscription item.
                      metadata:
                        type:
                          - object
                          - 'null'
                        additionalProperties:
                          type: string
                        description: >-
                          Set of key-value pairs to attach to the subscription
                          item.
                      price:
                        type: string
                        description: >-
                          The identifier of the price to use for the
                          subscription item.
                      price_data:
                        type: object
                        properties:
                          amount:
                            type: integer
                            description: The amount of the price.
                          currency:
                            type: string
                            description: The currency of the price.
                          tax_percent:
                            type: number
                            description: The tax percentage to apply to the price.
                        required:
                          - amount
                          - currency
                        description: The price data for the subscription item.
                      proration_behavior:
                        type: string
                        enum:
                          - create_prorations
                          - none
                        description: >-
                          Whether to create prorations when creating the
                          subscription item.
                      schedule:
                        type:
                          - array
                          - 'null'
                        items:
                          type: object
                          properties:
                            amount:
                              type: integer
                              description: The amount for the scheduled change.
                            effective_at:
                              type: integer
                              description: The date the scheduled change takes effect.
                            effective_at_config:
                              type: object
                              properties:
                                day:
                                  type: integer
                                  minimum: 1
                                  maximum: 31
                                  description: >-
                                    The day of the month the scheduled change
                                    takes effect.
                                month:
                                  type: integer
                                  minimum: 1
                                  maximum: 12
                                  description: The month the scheduled change takes effect.
                                year:
                                  type: integer
                                  description: The year the scheduled change takes effect.
                              required:
                                - day
                                - month
                                - year
                              description: >-
                                Configuration to compute the effective date of
                                the scheduled change.
                          required:
                            - amount
                        description: The schedule for the subscription item.
                      tax_rate:
                        type: string
                        description: >-
                          The identifier of the tax rate for the subscription
                          item.
                      transfer_behavior:
                        type: string
                        enum:
                          - automatic
                          - owner
                          - none
                        description: The transfer behavior for the subscription item.
                      transfer_destination:
                        type: string
                        description: >-
                          The identifier of the connected account to transfer
                          funds to.
                      type:
                        type: string
                        enum:
                          - charge
                          - rent
                          - product
                        description: The type of the subscription item.
                      unit:
                        type:
                          - string
                          - 'null'
                        description: >-
                          The identifier of the unit associated with the
                          subscription item.
                    required:
                      - price_data
                      - type
                  minItems: 1
                  maxItems: 10
                  description: >-
                    The items for the subscription. Required when interval is
                    not custom.
                use_future_billing_date:
                  type: boolean
                  description: Whether to use a future billing date for the first invoice.
              required:
                - collection_method
                - customer
                - interval
      responses:
        '200':
          description: Returns the subscription object if the request succeeded.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier for the object.
                  created:
                    type: number
                    description: >-
                      Time at which the object was created. Measured in seconds
                      since the Unix epoch.
                  account:
                    type: string
                    description: >-
                      The account that the object belongs to. Only returned if
                      the request is made with a valid Yorlet-Context header.
                  deleted:
                    type: boolean
                    default: false
                    description: Only returned if the object has been deleted.
                  object:
                    type: string
                    enum:
                      - subscription
                  application:
                    type:
                      - string
                      - 'null'
                    description: >-
                      The identifier of the application associated with the
                      subscription.
                  billing_anchor:
                    type:
                      - integer
                      - 'null'
                    description: >-
                      The reference point that aligns future billing cycle
                      dates.
                  billing_anchor_config:
                    type:
                      - object
                      - 'null'
                    properties:
                      day_of_month:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: The day of the month to anchor billing to.
                    required:
                      - day_of_month
                    description: Configuration for the billing anchor.
                  cancel_at:
                    type:
                      - integer
                      - 'null'
                    description: >-
                      The date at which the subscription will be automatically
                      canceled.
                  canceled_at:
                    type:
                      - integer
                      - 'null'
                    description: The date the subscription was canceled.
                  collection_method:
                    type: string
                    enum:
                      - charge_automatically
                      - send_invoice
                    description: The collection method for the subscription.
                  coupon:
                    type:
                      - string
                      - 'null'
                    description: The identifier of the coupon applied to the subscription.
                  currency:
                    type: string
                    enum:
                      - gbp
                      - usd
                      - eur
                      - sek
                    description: The currency of the subscription.
                    example: gbp
                  current_period_end:
                    type:
                      - integer
                      - 'null'
                    description: The end of the current billing period.
                  current_period_start:
                    type:
                      - integer
                      - 'null'
                    description: The start of the current billing period.
                  custom_fields:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          maxLength: 40
                          description: The name of the custom field.
                        value:
                          type: string
                          maxLength: 140
                          description: The value of the custom field.
                      required:
                        - name
                        - value
                    maxItems: 4
                    description: Custom fields attached to the subscription invoices.
                  customer:
                    anyOf:
                      - type: string
                      - type: object
                        properties:
                          id:
                            type: string
                            description: Unique identifier for the object.
                          created:
                            type: number
                            description: >-
                              Time at which the object was created. Measured in
                              seconds since the Unix epoch.
                          account:
                            type: string
                            description: >-
                              The account that the object belongs to. Only
                              returned if the request is made with a valid
                              Yorlet-Context header.
                          deleted:
                            type: boolean
                            default: false
                            description: Only returned if the object has been deleted.
                          object:
                            type: string
                            enum:
                              - customer
                          address:
                            type: object
                            properties:
                              line1:
                                type:
                                  - string
                                  - 'null'
                              line2:
                                type:
                                  - string
                                  - 'null'
                              city:
                                type:
                                  - string
                                  - 'null'
                              country:
                                type:
                                  - string
                                  - 'null'
                              postal_code:
                                type:
                                  - string
                                  - 'null'
                              state:
                                type:
                                  - string
                                  - 'null'
                            description: The customer's address.
                          default_payment_method:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: 'null'
                            description: ID of the default payment method for the customer.
                          delinquent:
                            type: boolean
                            description: >-
                              Whether the customer has any unpaid or past-due
                              invoices.
                          description:
                            type:
                              - string
                              - 'null'
                            description: An arbitrary description attached to the customer.
                          email:
                            type: string
                            format: email
                            description: The customer's email address.
                          invoice_prefix:
                            type: string
                            description: >-
                              The prefix for the customer used to generate
                              unique invoice numbers.
                          invoicing:
                            type: object
                            properties:
                              arrears_emails:
                                type: boolean
                                description: >-
                                  Whether the customer should receive arrears
                                  emails.
                              email_cc:
                                type: array
                                items:
                                  type: string
                                  format: email
                                description: Email addresses to CC on invoice emails.
                              email_to:
                                type:
                                  - string
                                  - 'null'
                                format: email
                                description: >-
                                  The primary email address to send invoices to.
                                  Defaults to the customer email when not set.
                            required:
                              - arrears_emails
                              - email_cc
                            description: Invoicing preferences for the customer.
                          legal:
                            type: object
                            properties:
                              dob:
                                type: object
                                properties:
                                  day:
                                    type:
                                      - integer
                                      - 'null'
                                    minimum: 1
                                    maximum: 31
                                  month:
                                    type:
                                      - integer
                                      - 'null'
                                    minimum: 1
                                    maximum: 12
                                  year:
                                    type:
                                      - integer
                                      - 'null'
                                    minimum: 1900
                                    maximum: 9999
                                required:
                                  - day
                                  - month
                                  - year
                                description: The customer's date of birth.
                              first_name:
                                type:
                                  - string
                                  - 'null'
                                description: The customer's legal first name.
                              last_name:
                                type:
                                  - string
                                  - 'null'
                                description: The customer's legal last name.
                            required:
                              - dob
                              - first_name
                              - last_name
                            description: Legal information about the customer.
                          metadata:
                            type:
                              - object
                              - 'null'
                            additionalProperties:
                              type: string
                            description: >-
                              Set of key-value pairs that you can attach to an
                              object. This can be useful for storing additional
                              information about the object in a structured
                              format.
                          name:
                            type:
                              - string
                              - 'null'
                            description: The customer's full name.
                          phone:
                            type:
                              - string
                              - 'null'
                            description: The customer's phone number.
                          radar:
                            type: object
                            properties:
                              message:
                                type:
                                  - string
                                  - 'null'
                                description: >-
                                  A human-readable message describing the radar
                                  assessment of the customer.
                              reason:
                                type:
                                  - string
                                  - 'null'
                                description: >-
                                  A machine-readable reason for the radar
                                  assessment of the customer.
                              risk_level:
                                type: string
                                description: >-
                                  The risk level assigned to the customer by
                                  radar.
                            required:
                              - message
                              - reason
                              - risk_level
                            description: Radar's risk assessment of the customer.
                        required:
                          - id
                          - created
                          - object
                          - address
                          - default_payment_method
                          - delinquent
                          - description
                          - email
                          - invoice_prefix
                          - invoicing
                          - legal
                          - name
                          - phone
                          - radar
                    description: The customer associated with the subscription.
                  days_before_collection:
                    type:
                      - integer
                      - 'null'
                    minimum: 0
                    maximum: 7
                    description: >-
                      The number of days before the due date to attempt
                      collection.
                  days_until_due:
                    type:
                      - integer
                      - 'null'
                    minimum: 0
                    description: The number of days until the invoice is due.
                  default_payment_method:
                    type:
                      - string
                      - 'null'
                    description: >-
                      The identifier of the default payment method for the
                      subscription.
                  description:
                    type:
                      - string
                      - 'null'
                    description: The description of the subscription.
                  end:
                    type:
                      - integer
                      - 'null'
                    description: The end date of the subscription.
                  interval:
                    type: string
                    enum:
                      - month
                      - week
                      - custom
                      - upfront
                    description: The billing interval for the subscription.
                  interval_count:
                    type:
                      - integer
                      - 'null'
                    description: The number of intervals between each billing cycle.
                  metadata:
                    type:
                      - object
                      - 'null'
                    additionalProperties:
                      type: string
                    description: Set of key-value pairs attached to the subscription.
                  next_period_end:
                    type:
                      - integer
                      - 'null'
                    description: The end of the next billing period.
                  next_period_start:
                    type:
                      - integer
                      - 'null'
                    description: The start of the next billing period.
                  pause_collection:
                    type:
                      - object
                      - 'null'
                    properties:
                      behavior:
                        type: string
                        enum:
                          - draft
                          - mark_uncollectible
                          - void
                        description: >-
                          The behavior to apply to invoices while collection is
                          paused.
                      resumes_at:
                        type:
                          - integer
                          - 'null'
                        description: The date at which collection will resume.
                    required:
                      - behavior
                      - resumes_at
                    description: The pause collection settings for the subscription.
                  payment_settings:
                    type:
                      - object
                      - 'null'
                    properties:
                      payment_method_types:
                        type: array
                        items:
                          type: string
                          enum:
                            - autogiro
                            - bacs_debit
                            - card
                            - card_present
                            - bank_transfer
                            - direct_transfer
                            - gbp_credit_transfer
                            - pay_by_bank
                            - sepa_debit
                        description: The payment method types allowed for the subscription.
                    required:
                      - payment_method_types
                    description: The payment settings for the subscription.
                  phases:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        start_date:
                          type: integer
                          description: The start date of the phase.
                        items:
                          type: array
                          items: {}
                          description: The items in the phase.
                      required:
                        - start_date
                        - items
                    description: The phases of the subscription.
                  start:
                    type: integer
                    description: The start date of the subscription.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - complete
                      - scheduled
                    description: The status of the subscription.
                required:
                  - id
                  - created
                  - object
                  - application
                  - billing_anchor
                  - billing_anchor_config
                  - cancel_at
                  - canceled_at
                  - collection_method
                  - coupon
                  - currency
                  - current_period_end
                  - current_period_start
                  - custom_fields
                  - customer
                  - days_before_collection
                  - days_until_due
                  - default_payment_method
                  - description
                  - end
                  - interval
                  - interval_count
                  - next_period_end
                  - next_period_start
                  - pause_collection
                  - payment_settings
                  - phases
                  - start
                  - status
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API Key authentication. Use "Bearer YOUR_API_KEY".

````