---
title: "Criar assinatura de plano"
url: "https://devcenter.stone.com.br/apis/v5-docs-legacy/versions/b9aaff36-6dcc-4353-8398-836d6c13dfa5/operations/criar-assinatura-de-plano-1"
---

> Full API specification: https://devcenter.stone.com.br/apis/v5-docs-legacy/versions/b9aaff36-6dcc-4353-8398-836d6c13dfa5.md

# Criar assinatura de plano

`POST` `/subscriptions`

Operation ID: `criar-assinatura-de-plano-1`

Fornecemos a possibilidade de criação de uma assinatura (`subscription`) a partir de plano (`plan`).

## Request body

Content types: `application/json`

## Responses

- `200` - 200
- `400` - 400

## OpenAPI definition

```yaml
openapi: 3.1.0
info:
  title: Pagar.me v5 API (Legado)
  version: 5.0.0
servers:
  - url: https://api.stone.com.br/core/v5
paths:
  /subscriptions:
    post:
      summary: Criar assinatura de plano
      description: Fornecemos a possibilidade de criação de uma assinatura
        (`subscription`) a partir de plano (`plan`).
      operationId: criar-assinatura-de-plano-1
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - plan_id
                - payment_method
                - customer_id
                - customer
                - card
              properties:
                code:
                  type: string
                  description: "Código da assinatura no sistema da loja. Máx.: 52 caracteres"
                plan_id:
                  type: string
                  description: "Código do plano.<br>Formato: `plan_XXXXXXXXXXXXXXXX`"
                payment_method:
                  type: string
                  description: "Meio de pagamento.<br>Valores possíveis: **credit_card**,
                    **boleto** e **debit_card** ."
                start_at:
                  type: string
                  description: Data de início da assinatura.<br>Se não for informada, a assinatura
                    será iniciada **imediatamente**.
                  format: date
                customer_id:
                  type: string
                  description: Código do cliente.<br>**Obrigatório** caso o `customer` não seja
                    informado. [Saiba mais sobre
                    clientes](https://docs.pagar.me/reference/clientes-1).
                customer:
                  type: object
                  description: Dados do cliente.<br>**Obrigatório** caso o `customer_id` não seja
                    informado. [Saiba mais sobre
                    clientes](https://docs.pagar.me/reference/clientes-1).
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      description: "Nome do cliente. Max: 64 caracteres."
                    type:
                      type: string
                      description: "Tipo de cliente. Valores possíveis: individual (pessoa física) ou
                        company (pessoa jurídica). Obrigatório, caso o document
                        seja enviado."
                    email:
                      type: string
                      description: "E-mail do cliente. Max: 64 caracteres."
                    code:
                      type: string
                      description: "Código de referência do cliente no sistema da loja. Max: 52
                        caracteres."
                    document:
                      type: string
                      description: "CPF, CNPJ ou PASSAPORTE do cliente. Max: 16 caracteres para CPF e
                        CNPJ e Max: 50 caracteres para PASSAPORTE."
                    document_type:
                      type: string
                      description: 'Tipo de documento. Valores possíveis: "CPF", "CNPJ" ou
                        "PASSPORT".'
                    gender:
                      type: string
                      description: "Sexo do cliente . Valores possíveis: male ou female."
                    address:
                      type: object
                      description: Endereço do cliente.
                      properties:
                        country:
                          type: string
                          description: País (Código do país no formato ISO 3166-1 alpha-2)(2 digitos)
                        state:
                          type: string
                          description: Estado (Código do estado no formato ISO 3166-2).
                        city:
                          type: string
                          description: Cidade.
                        zip_code:
                          type: string
                          description: Código Postal (CEP) (Apenas numérico).
                        line_1:
                          type: string
                          description: Dados principais do endereço. Neste campo deve ser informado
                            Número, Rua, Bairro, nesta ordem e separados por
                            vírgula.
                        line_2:
                          type: string
                          description: Dados complementares do endereço. Neste campo pode ser informado
                            complemento, referências.
                    phones:
                      type: object
                      description: Telefone residencial do cliente.
                      properties:
                        home_phone:
                          type: object
                          description: Telefone residencial do cliente.
                          properties:
                            country_code:
                              type: string
                              description: Código do País (Apenas numérico).
                            area_code:
                              type: string
                              description: Código da área (Apenas numérico).
                            number:
                              type: string
                              description: Número do telefone (Apenas numérico).
                        mobile_phone:
                          type: object
                          description: Telefone celular do cliente.
                          properties:
                            country_code:
                              type: string
                              description: Código do País (Apenas numérico).
                            area_code:
                              type: string
                              description: Código da área (Apenas numérico).
                            number:
                              type: string
                              description: Número do telefone (Apenas numérico).
                    birthdate:
                      type: string
                      description: Data de nascimento do cliente.
                      format: date
                    metadata:
                      type: string
                      description: Objeto chave/valor utilizado para armazenar informações adicionais
                        sobre o cliente.
                card:
                  type: object
                  description: Cartão que será utilizado na assinatura. <br>**- card_id** é o
                    código do cartão do cliente.<br>**- card_token** é token do
                    cartão gerado pelo checkout transparente. <br> É
                    **obrigatório** o envio de uma dessas identificações, caso o
                    **payment_method** seja credit_card ou debit_card.<br>[Saiba
                    mais sobre
                    cartões](https://docs.pagar.me/reference/cart%C3%B5es-1).
                  required:
                    - number
                    - holder_name
                    - exp_month
                    - exp_year
                  properties:
                    number:
                      type: string
                      description: Número do cartão. Entre 13 e 19 caracteres
                    holder_name:
                      type: string
                      description: Nome do portador como está impresso no cartão. Máximo de 64
                        caracteres (Caracteres especiais e números não são
                        aceitos)
                    holder_document:
                      type: string
                      description: CPF ou CNPJ do portador do cartão. Obrigatório caso o tipo do
                        cartão seja voucher (bandeiras VR ou Pluxee).
                    exp_month:
                      type: integer
                      description: Mês de validade do cartão. Valor entre 1 e 12 (inclusive)
                      format: int32
                    exp_year:
                      type: integer
                      description: "Ano de validade do cartão. Formatos yy ou yyyy. Ex: 23 ou 2023."
                      format: int32
                    cvv:
                      type: string
                      description: Código de segurança do cartão. O campo aceita 4 ou 3 caracteres,
                        variando por bandeira.
                    brand:
                      type: string
                      description: "(Opcional) Bandeira do cartão. Para cartões de crédito, temos como
                        valores possíveis: Elo, Mastercard, Visa, Amex, ou
                        Hipercard. Para voucher, temos como valores possíveis:
                        Alelo, Ticket, VR ou Pluxee."
                    label:
                      type: string
                      description: Indica a label do cartão
                    billing_address_id:
                      type: string
                      description: "Código do endereço de cobrança. Max: 36 caracteres.<>Opcional,
                        pode ser utilizado no lugar do billing_address."
                    billing_address:
                      type: object
                      properties:
                        line_1:
                          type: string
                          description: "Linha 1 do endereço. (Número, Rua, e Bairro - Nesta ordem e
                            separados por vírgula) Max: 256 caracteres."
                        line_2:
                          type: string
                          description: "Linha 2 do endereço. (Complemento - Andar, Sala, Apto). Max: 128
                            caracteres."
                        zip_code:
                          type: string
                          description: "CEP. Max: 16 caracteres."
                        city:
                          type: string
                          description: "Cidade. Max: 64 caracteres."
                        state:
                          type: string
                          description: Código do estado no formato ISO 3166-2.
                        country:
                          type: string
                          description: Código do país no formato ISO 3166-1 alpha-2.
                installments:
                  type: integer
                  description: Quantidade de parcelas.<br>O número de parcelas deverá ser 1 em
                    recorrências.
                  default: 1
                  format: int32
                discounts:
                  type: array
                  description: Descontos.
                  items:
                    properties:
                      cycles:
                        type: string
                        description: Número de vezes que o desconto será aplicado.
                      value:
                        type: string
                        description: Valor do desconto.
                      discount_type:
                        type: string
                        description: "Tipo do desconto. Valores possíveis: flat ou percentage. Valor
                          padrão: percentage."
                    type: object
                increments:
                  type: array
                  description: Incrementos
                  items:
                    properties:
                      value:
                        type: integer
                        description: Valor do incremento.
                        format: int32
                      cycles:
                        type: string
                        description: Número de vezes que o incremento será aplicado.
                      increment_type:
                        type: string
                        description: "Tipo do incremento. Valores possíveis: flat ou percentage. Valor
                          padrão: percentage."
                    type: object
                boleto_due_days:
                  type: integer
                  description: Dias para expiração do boleto. (Caso não seja passado, será pego um
                    valor padrão das configurações da loja)
                  format: int32
                metadata:
                  type: string
                  description: Objeto chave/valor utilizado para armazenar informações adicionais
                    sobre a assinatura.<br>[Saiba mais sobre
                    metadata](https://docs.pagar.me/reference/metadata-1).
            examples:
              JSON (with credit card):
                value:
                  plan_id: plan_21r4CTG0ux77Qv13
                  payment_method: credit_card
                  boleto_due_days: 5
                  customer:
                    name: Tony Stark
                    email: tonystark@avengers.com
                  card:
                    holder_name: Tony Stark
                    number: "4532464862385322"
                    exp_month: 1
                    exp_year: 30
                    cvv: "903"
                    billing_address:
                      line_1: 375, Av. General Justo, Centro
                      line_2: 8º andar
                      zip_code: "20021130"
                      city: Rio de Janeiro
                      state: RJ
                      country: BR
                  discounts:
                    - cycles: 3
                      value: 10
                      discount_type: percentage
                  increments:
                    - cycles: 2
                      value: 20
                      discount_type: percentage
                  metadata:
                    id: my_subscription_id
              JSON (with boleto):
                value:
                  plan_id: plan_21r4CTG0ux77Qv13
                  customer:
                    name: Tony Stark
                    email: tonystark@avengers.com
                  payment_method: boleto
      responses:
        "200":
          description: "200"
          content:
            application/json:
              examples:
                OK (with credit card):
                  value: |-
                    {
                        "id": "sub_05jkdIfGYPfN26mI",
                        "payment_method": "credit_card",
                        "currency": "BRL",
                        "interval": "month",
                        "interval_count": 3,
                        "billing_type": "prepaid",
                        "boleto_due_days":5,
                        "current_cycle": {
                            "start_at": "2016-07-19T00:00:00Z",
                            "end_at": "2016-10-18T23:59:59Z"
                        },
                        "next_billing_at": "2016-10-19T00:00:00Z",
                        "installments": 3,
                        "customer": {
                            "id": "cus_017228NmffGbA3d4",
                            "name": "Luke Skywalker",
                            "email": "lskywalker@r2d2.com",
                            "delinquent": false,
                            "created_at": "2016-07-12T18:25:40Z",
                            "updated_at": "2016-07-12T18:25:40Z"
                        },
                        "card": {
                            "id": "card_Mome2meGz4PDNQbX",
                            "holder_name": "Luke Skywalker",
                            "masked_number": "453246******5322",
                            "exp_month": 1,
                            "exp_year": 30,
                            "expired": false,
                            "status": "active",
                            "created_at": "2016-07-12T18:25:40Z",
                            "update_at": "2016-07-12T18:25:40Z",
                            "billing_address": {
                                "id": "addr_Mome2meGz4PDNQbX",
                                "line_1": "375, Av. General Justo, Centro",
                                "line_2": "8º andar",
                                "zip_code": "20021130",
                                "city": "Rio de Janeiro",
                                "state": "RJ",
                                "country": "BR",
                                "status": "active",
                                "created_at": "2016-07-12T18:25:40Z",
                                "updated_at": "2016-07-12T18:25:40Z"
                            }
                        },
                        "plan": {
                            "id": "plan_21r4CTG0ux77Qv13",
                            "name": "Plano Gold",
                            "url": "/plan_21r4CTG0ux77Qv13/academia/plano-gold",
                            "currency": "BRL",
                            "interval": "month",
                            "minimum_price": 10000,
                            "interval_count": 3,
                            "billing_type": "prepaid",
                            "installments": 3,
                            "status": "active",
                            "created_at": "2016-07-12T18:25:40Z",
                            "updated_at": "2016-07-12T18:25:40Z",
                            "metadata": {
                                "id": "my_plan_id"
                            }
                        },
                        "discounts": [
                            {
                                "id": "si_k2zpBDMsOs0fDfHe",
                                "cycles": 3,
                                "value": 10,
                                "discount_type": "percentage",
                                "created_at": "2016-07-12T18:25:40Z"
                            }
                        ],
                        "increments": [
                            {
                                "cycles": 2,
                                "value": 20,
                                "discount_type": "percentage"
                            }
                         ],
                        "items": [
                            {
                                "id": "si_B6555Riyq9lj6klS",
                                "description": "Musculação",
                                "quantity": 1,
                                "pricing_scheme": {
                                    "price": 18990
                                },
                                "status": "active",
                                "created_at": "2016-07-12T18:25:40Z",
                                "updated_at": "2016-07-12T18:25:40Z"
                            },
                            {
                                "id": "si_lFjtC2xYGttulJpn",
                                "description": "Matrícula",
                                "quantity": 1,
                                "cycles": 1,
                                "pricing_scheme": {
                                    "price": 5990
                                },
                                "status": "active",
                                "created_at": "2016-07-12T18:25:40Z",
                                "updated_at": "2016-07-12T18:25:40Z"
                            }
                        ],
                        "status": "active",
                        "created_at": "2016-07-12T18:25:40Z",
                        "updated_at": "2016-07-12T18:25:40Z",
                        "metadata": {
                            "id": "my_subscription_id"
                        }
                    }
                OK (with boleto):
                  value: >-
                    {
                        "id": "sub_bpYjMr9f8sA6QJNg",
                        "code": "XPLMBV9U10",
                        "start_at": "2018-04-04T00:00:00Z",
                        "interval": "month",
                        "interval_count": 1,
                        "billing_type": "postpaid",
                        "current_cycle": {
                            "id": "cycle_j6WnJ7ei1hW68bXo",
                            "start_at": "2018-04-04T00:00:00Z",
                            "end_at": "2018-05-03T23:59:59Z",
                            "billing_at": "2018-05-04T00:00:00Z"
                        },
                        "next_billing_at": "2018-05-04T00:00:00Z",
                        "payment_method": "boleto",
                        "currency": "BRL",
                        "statement_descriptor": "Spotify",
                        "installments": 1,
                        "status": "active",
                        "created_at": "2018-04-04T21:36:13Z",
                        "updated_at": "2018-04-04T21:36:13Z",
                        "customer": {
                            "id": "cus_qr2AgDGiOhr61Y5L",
                            "name": "Tony Stark",
                            "email": "cc25e912-197c-4626-a85d-8c0597e9b157@avengers.com",
                            "delinquent": false,
                            "created_at": "2018-04-04T21:36:13Z",
                            "updated_at": "2018-04-04T21:36:13Z",
                            "phones": {}
                        },
                        "plan": {
                            "id": "plan_85AK5eF15feLKM4J",
                            "name": "Premium",
                            "description": "Vá de Premium. E seja feliz!",
                            "url": "/plans/plan_85AK5eF15feLKM4J/pagarme-teste/premium",
                            "statement_descriptor": "Spotify",
                            "interval": "month",
                            "interval_count": 1,
                            "billing_type": "postpaid",
                            "payment_methods": [
                                "boleto",
                                "credit_card"
                            ],
                            "installments": [
                                1
                            ],
                            "status": "active",
                            "currency": "BRL",
                            "created_at": "2018-04-04T21:36:09Z",
                            "updated_at": "2018-04-04T21:36:09Z"
                        },
                        "items": [
                            {
                                "id": "si_xGw3AeYiaTJ639A6",
                                "name": "Name - Premium",
                                "description": "Test - Description",
                                "quantity": 1,
                                "status": "active",
                                "created_at": "2018-04-04T21:36:13Z",
                                "updated_at": "2018-04-04T21:36:13Z",
                                "pricing_scheme": {
                                    "price": 1490,
                                    "scheme_type": "unit"
                                }
                            }
                        ]
                    }
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: sub_bpYjMr9f8sA6QJNg
                  code:
                    type: string
                    example: XPLMBV9U10
                  start_at:
                    type: string
                    example: 2018-04-04T00:00:00Z
                  interval:
                    type: string
                    example: month
                  interval_count:
                    type: integer
                    example: 1
                    default: 0
                  billing_type:
                    type: string
                    example: postpaid
                  current_cycle:
                    type: object
                    properties:
                      id:
                        type: string
                        example: cycle_j6WnJ7ei1hW68bXo
                      start_at:
                        type: string
                        example: 2018-04-04T00:00:00Z
                      end_at:
                        type: string
                        example: 2018-05-03T23:59:59Z
                      billing_at:
                        type: string
                        example: 2018-05-04T00:00:00Z
                  next_billing_at:
                    type: string
                    example: 2018-05-04T00:00:00Z
                  payment_method:
                    type: string
                    example: boleto
                  currency:
                    type: string
                    example: BRL
                  statement_descriptor:
                    type: string
                    example: Spotify
                  installments:
                    type: integer
                    example: 1
                    default: 0
                  status:
                    type: string
                    example: active
                  created_at:
                    type: string
                    example: 2018-04-04T21:36:13Z
                  updated_at:
                    type: string
                    example: 2018-04-04T21:36:13Z
                  customer:
                    type: object
                    properties:
                      id:
                        type: string
                        example: cus_qr2AgDGiOhr61Y5L
                      name:
                        type: string
                        example: Tony Stark
                      email:
                        type: string
                        example: cc25e912-197c-4626-a85d-8c0597e9b157@avengers.com
                      delinquent:
                        type: boolean
                        example: false
                        default: true
                      created_at:
                        type: string
                        example: 2018-04-04T21:36:13Z
                      updated_at:
                        type: string
                        example: 2018-04-04T21:36:13Z
                      phones:
                        type: object
                        properties: {}
                  plan:
                    type: object
                    properties:
                      id:
                        type: string
                        example: plan_85AK5eF15feLKM4J
                      name:
                        type: string
                        example: Premium
                      description:
                        type: string
                        example: Vá de Premium. E seja feliz!
                      url:
                        type: string
                        example: /plans/plan_85AK5eF15feLKM4J/pagarme-teste/premium
                      statement_descriptor:
                        type: string
                        example: Spotify
                      interval:
                        type: string
                        example: month
                      interval_count:
                        type: integer
                        example: 1
                        default: 0
                      billing_type:
                        type: string
                        example: postpaid
                      payment_methods:
                        type: array
                        items:
                          type: string
                          example: boleto
                      installments:
                        type: array
                        items:
                          type: integer
                          example: 1
                          default: 0
                      status:
                        type: string
                        example: active
                      currency:
                        type: string
                        example: BRL
                      created_at:
                        type: string
                        example: 2018-04-04T21:36:09Z
                      updated_at:
                        type: string
                        example: 2018-04-04T21:36:09Z
                  items:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          example: si_xGw3AeYiaTJ639A6
                        name:
                          type: string
                          example: Name - Premium
                        description:
                          type: string
                          example: Test - Description
                        quantity:
                          type: integer
                          example: 1
                          default: 0
                        status:
                          type: string
                          example: active
                        created_at:
                          type: string
                          example: 2018-04-04T21:36:13Z
                        updated_at:
                          type: string
                          example: 2018-04-04T21:36:13Z
                        pricing_scheme:
                          type: object
                          properties:
                            price:
                              type: integer
                              example: 1490
                              default: 0
                            scheme_type:
                              type: string
                              example: unit
        "400":
          description: "400"
          content:
            application/json:
              examples:
                Result:
                  value: "{}"
              schema:
                type: object
                properties: {}
      deprecated: false
      x-readme:
        code-samples:
          - language: csharp
            code: >-
              using System.Collections.Generic;

              using System.Web.Mvc;

              using MundiAPI.PCL;

              using MundiAPI.PCL.Models;


              namespace MundipaggTest.Controllers {

                  public class HomeController : Controller {

                      public ActionResult Index () {

                          // Secret key fornecida pela Mundipagg
                          string basicAuthUserName = "SUA_CHAVE_SECRETA";
                          // Senha em branco. Passando apenas a secret key
                          string basicAuthPassword = "";

                          var client = new MundiAPIClient (basicAuthUserName, basicAuthPassword);

                          string planId = "plan_21r4CTG0ux77Qv13";

                          var billinAddress = new CreateAddressRequest {
                              Line1 = "375, Av. General Justo, Centro",
                              Line2 = "8º andar",
                              ZipCode = "20021130",
                              City = "Rio de Janeiro",
                              State = "RJ",
                              Country = "BR"
                          };

                          var card = new CreateCardRequest {
                              HolderName = "Tony Stark",
                              Number = "4532464862385322",
                              ExpMonth = 1,
                              ExpYear = 30,
                              Cvv = "903",
                              BillingAddress = billinAddress
                          };

                          var discounts = new List<CreateDiscountRequest> {
                              new CreateDiscountRequest {
                              Cycles = 3,
                              Value = 10,
                              DiscountType = "percentage"
                              }
                          };

                          var metadata = new Dictionary<string, string> ();
                          metadata.Add ("id", "my_subscription_id");

                          var request = new CreateSubscriptionRequest {
                              PlanId = planId,
                              PaymentMethod = "credit_card",
                              Currency = "BRL",
                              Interval = "month",
                              IntervalCount = 3,
                              BillingType = "prepaid",
                              Installments = 3,
                              Customer = new CreateCustomerRequest {
                              Name = "Tony Stark",
                              Email = "tonystark@avengers.com"
                              },
                              Card = card,
                              Discounts = discounts,
                              Metadata = metadata
                          };

                          var response = client.Subscriptions.CreateSubscription (request);

                          return View ();
                      }
                  }
              }
            name: SDK C#
        samples-languages:
          - csharp
security:
  - sec0: []
components:
  securitySchemes:
    sec0:
      type: http
      scheme: basic
```
