> For the complete documentation index, see [llms.txt](https://docs.tebex.io/developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tebex.io/developers/headless-api/guides/baskets/create-a-basket.md).

# Create a Basket

For most stores, you can create a basket without any required parameters. For certain store types you may need to provide additional information.

### Minecraft and Overwolf Stores

You must provide the `username` parameter as part of the basket creation request so that the basket is attributed to the correct user.

The returned basket will contain a `username_id` which can safely be added to the user's session. It is required for use with certain endpoints across Tebex APIs.

### Backend Servers

If you are creating a basket on your backend server, you must provide an `ip_address`  on creation, otherwise the basket will be incorrectly attributed to your server's IP.

### Universal Stores

No `username` is required for your basket. Depending on your package **Deliverables** you may need to provide `variable_data` per each Package so that it is attributed to the correct user. See [Add Package to Basket](/developers/headless-api/guides/baskets/add-package-to-basket.md).

```json
{
  "complete_url": "https://example.tebex.io/thank-you",
  "cancel_url": "https://tebex.io/",
  "custom": {
    "foo": "bar"
  },
  "complete_auto_redirect": true,
  "ip_address": "127.0.0.1"
}
```

## Create a new basket

> Creates a new basket for use during checkout.

```json
{"openapi":"3.1.0","info":{"title":"Tebex Headless API","version":"2.0.0"},"tags":[{"name":"Headless","description":"Main API scoped to public token"}],"servers":[{"url":"https://headless.tebex.io/api/accounts/{token}","description":"Main API scoped to public token","variables":{"token":{"default":"","description":"The store's public token"}}}],"paths":{"/baskets":{"post":{"tags":["Headless"],"operationId":"createBasket","summary":"Create a new basket","description":"Creates a new basket for use during checkout.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"complete_url":{"type":"string","description":"A URL the user can return to when checkout is completed."},"cancel_url":{"type":"string","description":"A URL the user can return to when cancelling checkout."},"custom":{"type":"object","description":"Custom data you wish to associate with the basket. This data will be included with webhook responses and GET requests associated with the Basket."},"complete_auto_redirect":{"type":"boolean","description":"True if the user should automatically be redirected to the relevant complete/cancel URL"}}}}}},"responses":{"200":{"description":"Successful response returns the basket information.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BasketResponse"}}}},"422":{"description":"The provided webstore ID is invalid."}}}}},"components":{"schemas":{"BasketResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Basket"}}},"Basket":{"type":"object","properties":{"id":{"type":"string"},"ident":{"type":"string"},"complete":{"type":"boolean"},"email":{"type":"string","nullable":true},"username":{"type":"string","nullable":true},"coupons":{"type":"array","items":{"$ref":"#/components/schemas/Coupon"}},"giftcards":{"type":"array","items":{"$ref":"#/components/schemas/GiftCard"}},"creator_code":{"type":"string","description":"The creator code is used to share a percentage of the payment with another party. See more about creator codes at https://docs.tebex.io/creators/tebex-control-panel/engagement/creator-codes"},"cancel_url":{"type":"string"},"complete_url":{"type":"string","nullable":true},"complete_auto_redirect":{"type":"boolean"},"country":{"type":"string","description":"A two-character country code"},"ip":{"type":"string"},"username_id":{"type":"integer"},"base_price":{"type":"number","format":"float"},"sales_tax":{"type":"number","format":"float"},"total_price":{"type":"number","format":"float"},"currency":{"type":"string","description":"A 3 character currency code"},"packages":{"type":"array","items":{"$ref":"#/components/schemas/BasketPackage"}},"custom":{"type":"object","nullable":true},"links":{"$ref":"#/components/schemas/BasketLinks"}}},"Coupon":{"type":"object","properties":{"code":{"type":"string"}}},"GiftCard":{"type":"object","properties":{"card_number":{"type":"string"}}},"BasketPackage":{"type":"object","description":"A package within an existing basket.","properties":{"id":{"type":"integer","description":"The package ID"},"description":{"type":"string"},"image":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"in_basket":{"type":"object","properties":{"quantity":{"type":"integer","description":"The quantity of `package` in this basket. This is not the total quantity of overall items in the basket."},"price":{"type":"number","format":"float"},"gift_username_id":{"type":"string","description":"The username id of the user this package is gifted to"},"gift_username":{"type":"string","description":"The username of the user this package is gifted to."}}},"type":{"type":"string","enum":["single","subscription"],"description":"The type of payment, either `single` for one-time payments or `subscription`."},"revenue_share":{"type":"array","description":"An array of payment destination objects describing how the purchase should be split between multiple wallets. **Only available with pre-agreement from Tebex.**","items":{"$ref":"#/components/schemas/RevenueShare"}}}},"RevenueShare":{"type":"object","properties":{"wallet_ref":{"type":"string"},"amount":{"type":"number","description":"A float (decimal) value representing the amount of this payment in your account currency that is credited to the `wallet_ref`"},"gateway_fee_percent":{"type":"number","description":"A float (decimal) value representing the percentage of the gateway fee that should be dedicated from this wallet’s revenue share. This optional value can be anywhere between 0 - 100."}}},"BasketLinks":{"type":"object","properties":{"payment":{"type":"string","description":"The `links.payment` property is only returned if the basket has been paid for and a payment exists with the `complete`,`refund`, or `chargeback` status."},"checkout":{"type":"string","description":"The `links.checkout` property is only returned if the basket has not been paid, and is the URL to send the customer to make payment"}}}}}}
```
