# Create checkout

Source: https://docs.orbytelabs.com/api-reference/top-ups/createTopupCheckout

## POST /v1/topups/checkout

```json
{
  "operationId": "createTopupCheckout",
  "tags": [
    "Top-ups"
  ],
  "summary": "Buy additional credits through Stripe Checkout",
  "description": "Creates or reuses the customer in this environment and on Stripe; no subscription is required to buy or spend credits. Purchased credits can fund any deployed feature by default, including features added later. Set featureKeys to restrict access to distinct keys from the active deployment. An empty list grants no feature access. Stripe Checkout records the feature scope and expiry in metadata. Features need not belong to a plan. One displayed credit costs $1 USD. credits uses integer ledger units, where one credit is 1000000000 units. Amounts must be exact cents, between $0.50 and $999999.99. Optional expiresAt is an absolute Unix timestamp in milliseconds, in the future when checkout is created; omitted means no expiry. The same expiry applies even if payment confirmation arrives later. Each call creates a new Stripe Checkout session, where customers can save eligible cards for future purchases. Successful payments grant credits through Stripe webhooks. Stripe creates paid invoices by default unless the environment disables them.",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "schema": {
        "type": "string",
        "minLength": 1,
        "description": "Required for environment-scoped OAuth operations. API keys remain bound to their own environment."
      },
      "required": false,
      "description": "Required for environment-scoped OAuth operations. API keys remain bound to their own environment.",
      "name": "X-Orbyte-Environment",
      "in": "header"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "properties": {
            "identity": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "successUrl": {
              "type": "string",
              "maxLength": 2048,
              "format": "uri"
            },
            "cancelUrl": {
              "type": "string",
              "maxLength": 2048,
              "format": "uri"
            },
            "credits": {
              "type": "string",
              "pattern": "^-?(0|[1-9][0-9]*)$",
              "maxLength": 20
            },
            "featureKeys": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "^[a-z][a-z0-9_-]*$"
              }
            },
            "expiresAt": {
              "description": "Optional credit expiration as a Unix timestamp in milliseconds. Must be in the future when checkout is created.",
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "identity",
            "successUrl",
            "cancelUrl",
            "credits"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Checkout session awaiting payment",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^cs_.*"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "id",
              "url"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "400": {
      "description": "Invalid request",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "401": {
      "description": "Unauthorized",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "403": {
      "description": "Insufficient permission",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "404": {
      "description": "Resource not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "409": {
      "description": "Resource or request conflict",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "413": {
      "description": "Content too large",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "415": {
      "description": "Unsupported media type",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "500": {
      "description": "Unexpected server error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    }
  }
}
```

Complete schema: [OpenAPI 3.1 document](https://docs.orbytelabs.com/openapi.json)