# Checkout

## Create a checkout session

> Creates a checkout session from a secure server using an API Key.\
> If you have a Customer token, see the Storefront API Create Checkout endpoint.

OpenAPI:

```json
{"openapi":"3.0.4","info":{"title":"PayNow Management API","version":"v1"},"security":[{"APIKey":[]}],"components":{"securitySchemes":{"APIKey":{"type":"apiKey","description":"An API Key token generated in the Dashboard in the format 'APIKey TOKEN_HERE'.","name":"Authorization","in":"header"}}},"paths":{"/v1/stores/{storeId}/checkouts":{"post":{"tags":["checkout"],"summary":"Create a checkout session","description":"Creates a checkout session from a secure server using an API Key.\nIf you have a Customer token, see the Storefront API Create Checkout endpoint.","operationId":"StoreCheckouts_CreateCheckoutSession","parameters":[{"name":"storeId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"required":["auto_redirect","customer_id","lines","subscription"],"type":"object","properties":{"lines":{"type":"array","items":{"required":["quantity","subscription"],"type":"object","properties":{"subscription":{"type":"boolean","description":"Determines whether this line should create a subscription"},"gift_to":{"required":["id","platform"],"type":"object","properties":{"platform":{"enum":["invalid","steam","minecraft","paynow_name"],"type":"string","description":"A customer platform type used while gifting"},"id":{"type":"string","description":"The account ID on the platform"}},"additionalProperties":false,"description":"Represents a customer platform association, used for gifting"},"gift_to_customer_id":{"type":"string","additionalProperties":false,"format":"flake-id"},"quantity":{"type":"integer","description":"The quantity of this product to purchase","format":"int32"},"selected_gameserver_id":{"type":"string","additionalProperties":false,"format":"flake-id"},"metadata":{"type":"object","additionalProperties":{"type":"string"},"description":"Optional metadata to associate with the checkout session line.\nDo not store any sensitive information here.","nullable":true},"custom_variables":{"type":"object","additionalProperties":{"type":"string"},"description":"Key-value pair mapping custom variable identifiers to their selected values.\nRequired only when the product includes custom variables.","nullable":true},"product_id":{"type":"string","additionalProperties":false,"format":"flake-id"},"inline_product":{"type":"object","properties":{"slug":{"type":"string","description":"The unique URL-safe identifier (slug) for the product.","nullable":true},"name":{"type":"string","description":"The display name of the product.","nullable":true},"description":{"type":"string","description":"The detailed description of the product.","nullable":true},"label":{"type":"string","description":"The display label for the product.","nullable":true},"price":{"type":"integer","description":"The price of the product in the lowest denominator (e.g. cents).","format":"int64","nullable":true},"single_game_server_only":{"type":"boolean","description":"Indicates whether the customer is prompted to select a game server before purchasing.","nullable":true},"allow_one_time_purchase":{"type":"boolean","description":"Indicates whether one-time purchases are allowed.","nullable":true},"allow_subscription":{"type":"boolean","description":"Indicates whether subscription purchases are allowed.","nullable":true},"subscription_interval_value":{"type":"integer","description":"The subscription interval value.","format":"int32","nullable":true},"subscription_interval_scale":{"enum":["invalid","day","week","month","year"],"type":"string"},"remove_after_enabled":{"type":"boolean","description":"Indicates whether automatic removal is enabled.","nullable":true},"remove_after_time_value":{"type":"integer","description":"The time value for automatic removal.","format":"int32","nullable":true},"remove_after_time_scale":{"enum":["invalid","day","week","month"],"type":"string"},"store_stock_limit":{"required":["enabled","time_scale"],"type":"object","properties":{"enabled":{"type":"boolean","description":"Indicates whether stock limit is enabled."},"quantity":{"type":"integer","description":"The quantity limit.","format":"int32","nullable":true},"time_value":{"type":"integer","description":"The time value for stock limit period.","format":"int32","nullable":true},"time_scale":{"enum":["invalid","day","week","month","year"],"type":"string"}},"additionalProperties":false},"customer_stock_limit":{"required":["enabled","time_scale"],"type":"object","properties":{"$ref":"#/paths/~1v1~1stores~1{storeId}~1checkouts/post/requestBody/content/application~1json/schema/properties/lines/items/properties/inline_product/properties/store_stock_limit/properties"},"additionalProperties":false},"stock_limit_do_not_include_removed":{"type":"boolean","description":"Indicates whether removed items should be excluded from stock limits.","nullable":true},"tags":{"type":"array","items":{"type":"string","additionalProperties":false,"format":"flake-id"},"description":"The tag IDs associated with the product.","nullable":true},"gameservers":{"type":"array","items":{"type":"string","additionalProperties":false,"format":"flake-id"},"description":"The gameserver IDs associated with the product.","nullable":true},"commands":{"type":"array","items":{"required":["content","online_only","stage"],"type":"object","properties":{"stage":{"enum":["invalid","on_purchase","on_expire","on_refund","on_renew","on_chargeback"],"type":"string","description":"Defines the stages at which product commands can be executed."},"content":{"type":"string","description":"Content of the command."},"online_only":{"type":"boolean","description":"Value indicating whether the command should only execute when the player is online."},"override_execute_on_gameserver_ids":{"type":"array","items":{"type":"string","additionalProperties":false,"format":"flake-id"},"description":"Value indicating on which game servers should the command be executed.\nIf left empty or null, then the default behavior applies\n(executing on all game servers or on the selected game server is selection is enabled)","nullable":true}},"additionalProperties":false},"description":"The commands to be executed at different stages.","nullable":true},"deliverable_actions":{"required":["grant_giftcard"],"type":"object","properties":{"grant_giftcard":{"type":"boolean","description":"Value indicating whether to grant a giftcard with the product with the subtotal amount."}},"additionalProperties":false},"metadata":{"type":"object","additionalProperties":{"type":"string"},"description":"Additional metadata for the product.","nullable":true},"payout_splits":{"type":"array","items":{"required":["platform_fee","user_id"],"type":"object","properties":{"user_id":{"type":"string","additionalProperties":false,"format":"flake-id"},"percentage":{"type":"integer","description":"The percentage of the payment allocated to the user, in basis points (500 = 5%).\nThe last payout split must have this field set to `null` to receive the remaining portion.","format":"int64","nullable":true},"platform_fee":{"type":"integer","description":"The platform fee percentage your platform receives, in basis points (500 = 5%).","format":"int64"}},"additionalProperties":false},"description":"The payout splits for revenue distribution.\nRequires special approval.","nullable":true},"tax_code":{"enum":["unknown","digital_goods_subscription","digital_goods_permanent","saas","downloaded_software","digital_goods_subscription_gaming","digital_goods_permanent_gaming"],"type":"string","description":"Determines the category of the product for taxation purposes.\nContact support for help with setting the correct tax code."},"allow_concurrent_active_items":{"type":"boolean","description":"Indicates whether concurrent active items are allowed.","nullable":true},"disable_promo_codes":{"type":"boolean","description":"Indicates whether using coupons and gift cards on this product is allowed.","nullable":true},"is_hidden":{"type":"boolean","description":"Indicates whether the product is hidden.","nullable":true},"is_gifting_disabled":{"type":"boolean","description":"Indicates whether gifting is disabled.","nullable":true},"enabled_at":{"type":"string","description":"The date and time when the product becomes enabled.\nSet to `null` to keep enabled.","format":"date-time","nullable":true},"enabled_until":{"type":"string","description":"The date and time until which the product remains enabled.\nSet to `null` to keep enabled.","format":"date-time","nullable":true},"required_product_ids":{"type":"array","items":{"type":"string","additionalProperties":false,"format":"flake-id"},"description":"The IDs of products required for purchasing this product.","nullable":true},"required_product_all":{"type":"boolean","description":"Indicates whether all required products are needed.","nullable":true},"custom_variable_ids":{"type":"array","items":{"type":"string","additionalProperties":false,"format":"flake-id"},"description":"The IDs of associated custom variables.","nullable":true}},"additionalProperties":false,"description":"Optional inline product definition for dynamic products.\nRequires special approval, use `product_id` instead."}},"additionalProperties":false,"description":"Represents a line item in a checkout session request.\nOpposed to CreateCheckoutSessionLineDto, this is used while creating a checkout session using the Management API,\nand allows for creating inline products (which is subject to special approval)"},"description":"The line items to include in the checkout"},"subscription":{"type":"boolean","description":"Whether this checkout creates a subscription.\nDEPRECATED: Use 'subscription' field in 'lines' array objects instead.","deprecated":true},"coupon_id":{"type":"string","additionalProperties":false,"format":"flake-id"},"affiliate_code":{"type":"string","description":"Optional affiliate code to track referrals","nullable":true},"return_url":{"type":"string","description":"Optional URL to redirect to after successful checkout","nullable":true},"cancel_url":{"type":"string","description":"Optional URL to redirect to if checkout is canceled","nullable":true},"auto_redirect":{"type":"boolean","description":"Whether to automatically redirect the customer (return_url must be set)"},"metadata":{"type":"object","additionalProperties":{"type":"string"},"description":"Optional metadata to associate with the checkout session.\nDo not store any sensitive information here.","nullable":true},"customer_id":{"type":"string","additionalProperties":false,"format":"flake-id"}},"additionalProperties":false,"description":"Request to create a new checkout session from your back-end server using the management API.\n`customer_id` needs to be specified explicitly here instead of using a Customer token."}},"text/json":{"schema":{"required":["auto_redirect","customer_id","lines","subscription"],"type":"object","properties":{"$ref":"#/paths/~1v1~1stores~1{storeId}~1checkouts/post/requestBody/content/application~1json/schema/properties"},"additionalProperties":false,"description":"Request to create a new checkout session from your back-end server using the management API.\n`customer_id` needs to be specified explicitly here instead of using a Customer token."}},"application/*+json":{"schema":{"required":["auto_redirect","customer_id","lines","subscription"],"type":"object","properties":{"$ref":"#/paths/~1v1~1stores~1{storeId}~1checkouts/post/requestBody/content/application~1json/schema/properties"},"additionalProperties":false,"description":"Request to create a new checkout session from your back-end server using the management API.\n`customer_id` needs to be specified explicitly here instead of using a Customer token."}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"required":["id","token","url"],"type":"object","properties":{"id":{"type":"string","additionalProperties":false,"format":"flake-id"},"token":{"type":"string","description":"The token for the checkout session"},"url":{"type":"string","description":"The URL to redirect the customer to complete checkout"}},"additionalProperties":false,"description":"Response after creating a checkout session"}}}},"default":{"description":"Error response","content":{"application/json":{"schema":{"required":["code","message","status"],"type":"object","properties":{"status":{"type":"integer","description":"The HTTP status code.","format":"int32"},"code":{"type":"string","description":"The PayNow parseable error code."},"message":{"type":"string","description":"The human-readable error message."},"trace_id":{"type":"string","description":"A distributed trace ID used for debugging.","nullable":true},"errors":{"type":"array","items":{"required":["code","message","path","validation"],"type":"object","properties":{"code":{"type":"string","description":"The parseable error code."},"message":{"type":"string","description":"The human-readable error message."},"path":{"type":"string","description":"The path leading to the validation error."},"validation":{"type":"string","description":"Type of the validation that failed."}},"additionalProperties":false,"description":"A validation error."},"description":"An array of multiple errors. Only used by some API services.","nullable":true}},"additionalProperties":false,"description":"Represents a PayNow error"}}}}}}}}}
```
