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

# Create a Subscription

# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "Monetization",
    "version": "1.0.0",
    "description": ""
  },
  "servers": [
    {
      "url": "https://api.zype.com/"
    }
  ],
  "security": [
    {
      "api_key": []
    }
  ],
  "components": {
    "securitySchemes": {
      "api_key": {
        "type": "apiKey",
        "name": "api_key",
        "in": "query"
      }
    }
  },
  "paths": {
    "/subscriptions": {
      "post": {
        "summary": "Create a Subscription",
        "description": "",
        "tags": [
          "Subscriptions"
        ],
        "operationId": "createSubscription",
        "requestBody": {
          "description": "",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "title": "SubscriptionRequest",
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Use this parameter to indicate the subscription type ('stripe', 'braintree' or 'recurly'). This value is **required only** when the subscription type cannot be inferred automatically via its specific attributes (for example when creating a Stripe subscription with a 100% discount coupon where no stripe_id or stripe_card_token is passed)."
                  },
                  "subscription": {
                    "title": "SubscriptionProperties",
                    "required": [
                      "plan_id",
                      "consumer_id"
                    ],
                    "type": "object",
                    "properties": {
                      "consumer_id": {
                        "type": "string"
                      },
                      "plan_id": {
                        "type": "string"
                      },
                      "third_party_id": {
                        "description": "The id of a third party plan. required if not using recurly, braintree or stripe.\n*Note*: third_party_id can’t have unicode characters in the name. Only alphanumeric characters are allowed (Example: apple123)",
                        "type": "string"
                      },
                      "coupon_code": {
                        "description": "The code of the coupon, if used.",
                        "type": "string"
                      },
                      "stripe_card_token": {
                        "description": "The Stripe credit card token as generated by a Stripe payment form",
                        "type": "string"
                      },
                      "stripe_id": {
                        "description": "The id of a Stripe subscription that has already been fully created (used for reconciling the Zype dashboard with subscriptions that have been previously created)",
                        "type": "string"
                      },
                      "stripe_metadata": {
                        "description": "Custom Stripe Metadata can be added, updated, and removed from Zype Subscription objects corresponding to a Stripe Subscription.  Metdata will be persisted in Stripe and Zype Platforms.\nTo add or update Stripe metadata use URL or JSON syntax: `subscription[stripe_metadata]key1=value1&subscripition[stripe_metadata]key2=value2`\nTo remove a Stripe metadata key/value pair, include the key to be removed, but do not set a value: `subscription[stripe_metadata]key1&subscripition[stripe_metadata]key2`",
                        "type": "object"
                      },
                      "braintree_payment_nonce": {
                        "description": "The Braintree credit card payment nonce as generated by a Braintree payment form",
                        "type": "string"
                      },
                      "braintree_id": {
                        "description": "The id of a Braintree subscription that has already been fully created (used for reconciling the Zype dashboard with subscriptions that have been previously created)",
                        "type": "string"
                      },
                      "recurly_token_id": {
                        "description": "The Recurly credit card token ID by a Recurly.js payment form",
                        "type": "string"
                      },
                      "recurly_uuid": {
                        "description": "The uuid of a Recurly subscription that has already been fully created (used for reconciling the Zype dashboard with subscriptions that have been previously created)",
                        "type": "string"
                      },
                      "status": {
                        "description": "Valid values are ‘canceled’, ‘active’ or ‘paused’ (Stripe only). If left empty, ‘active’ will be the default value. When ‘paused’, use ‘active’ to resume the cycle.",
                        "type": "string"
                      },
                      "cancelled_at": {
                        "description": "If the subscription has already been cancelled at a certain date",
                        "type": "string"
                      },
                      "cancel_at_period_end": {
                        "description": "Set Stripe subscription to cancel at period end (Stripe only)",
                        "type": "boolean"
                      },
                      "trial_end": {
                        "description": "Unix timestamp to set Stripe subscription's trial_end value (Stripe only). Overrides Zype's trialing logic.",
                        "type": "string"
                      },
                      "trial_from_plan": {
                        "description": "Set Stripe subscription's trial_from_plan (Stripe only). Overrides Zype's trialing logic.",
                        "type": "boolean"
                      },
                      "current_period_start_at": {
                        "description": "Set the beginning of the subscription period. *Only applies to Recurly and third party subscriptions* Either `current_period_start_at` or `current_period_end_at` should be set, *but not both*.",
                        "type": "string"
                      },
                      "current_period_end_at": {
                        "description": "Set the end of the subscription period. *Only applies to third party subscriptions* (`third_party_id` field should be present). Either `current_period_start_at` or `current_period_end_at` should be set, *but not both*.",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "title": "SubscriptionResponse",
                  "type": "object",
                  "properties": {
                    "response": {
                      "title": "Subscription",
                      "type": "object",
                      "properties": {
                        "_id": {
                          "type": "string"
                        },
                        "amount": {
                          "description": "Amount the subscription costs (3.99)",
                          "type": "integer"
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "currency": {
                          "description": "will match the Plan's currency",
                          "type": "string"
                        },
                        "current_period_end_at": {
                          "type": "string"
                        },
                        "current_period_start_at": {
                          "type": "string"
                        },
                        "discount_amount": {
                          "type": "number"
                        },
                        "discount_duration": {
                          "type": "string",
                          "description": "How long the discount will be valid"
                        },
                        "discount_duration_months": {
                          "description": "How many months the discount will be valid",
                          "type": "number"
                        },
                        "discount_percent": {
                          "description": "Percentage off total price",
                          "type": "number"
                        },
                        "mrr": {
                          "description": "Monthly Recurring Revenue",
                          "type": "number"
                        },
                        "site_id": {
                          "type": "string"
                        },
                        "start_at": {
                          "type": "string"
                        },
                        "trial_period_days": {
                          "description": "Number of days a trial will last",
                          "type": "number"
                        },
                        "updated_at": {
                          "type": "string"
                        },
                        "plan_name": {
                          "type": "string"
                        },
                        "consumer_id": {
                          "type": "string"
                        },
                        "plan_id": {
                          "type": "string"
                        },
                        "third_party_id": {
                          "type": "string"
                        },
                        "stripe_card_token": {
                          "description": "The Stripe credit card token as generated by a Stripe payment form",
                          "type": "string"
                        },
                        "stripe_id": {
                          "type": "string"
                        },
                        "braintree_payment_nonce": {
                          "type": "string"
                        },
                        "braintree_id": {
                          "type": "string"
                        },
                        "recurly_token_id": {
                          "type": "string"
                        },
                        "recurly_uuid": {
                          "type": "string"
                        },
                        "status": {
                          "description": "Valid values are ‘canceled’, ‘active’ or ‘paused’ (Stripe only). If left empty, ‘active’ will be the default value. When ‘paused’, use ‘active’ to resume the cycle.",
                          "type": "string"
                        },
                        "days_remaining": {
                          "description": "When the status is ‘active’, the days remaining in the current cycle. When ‘canceled’, the value returned is 0. When ‘paused’ (Stripe only), the days remaining before pausing.",
                          "type": "integer"
                        },
                        "cancelled_at": {
                          "type": "string"
                        },
                        "cancel_at_period_end": {
                          "description": "Set Stripe subscription to cancel at period end",
                          "type": "boolean"
                        },
                        "coupon_code": {
                          "description": "The code of the coupon, if used.",
                          "type": "string"
                        },
                        "payment_provider": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/paths/~1plans/post/responses/422/content/application~1json/schema"
                }
              }
            }
          }
        }
      }
    }
  }
}
```