# Authentication and environments

Create Kustom API credentials and use HTTP Basic authentication. Choose the correct base URL and credentials for the production or playground environment.

Every Kustom API call is authenticated with HTTP Basic auth, using an **API username** and an
**API password** created for your Merchant ID, and every call goes to one of two base URLs
depending on whether you are testing or taking real money. This page gets you working
credentials and shows you a request that uses them. You need an
email address and nothing else — the playground account is free and self-serve.

## Base URLs

Build every request as base URL plus endpoint path. Production and playground are separate
environments, each with its own credentials.

| Environment | API base URL | Portal |
|---|---|---|
| Production | `https://api.kustom.co/` | `https://portal.kustom.co/` |
| Playground | `https://api.playground.kustom.co/` | `https://portal.playground.kustom.co/` |

So a create-order call in the playground goes to
`https://api.playground.kustom.co/checkout/v3/orders`.

## Before you start

You need a Kustom Playground account. It takes about two minutes:

1. Open the [Playground onboarding form](https://portal.playground.kustom.co/onboarding).
2. Enter your store name and the email address you want the account associated with.
3. Submit. You will get a confirmation email containing a link to the Playground Portal.
4. Open that link and sign in with Microsoft SSO, Google SSO or a magic link.

## Step by step

**1. Create API credentials in the Portal.** In the Playground Portal, go to **Developers →
API** and click **Generate new**. You get two values:

- The **API username**, in the form `<MID>-<randomsuffix>`. The Portal labels it **Key ID**.
  It contains your Merchant ID but is not the Merchant ID itself.
- The **API password**, which starts `kco_live_api_` in production and `kco_test_api_` in
  playground. Save it immediately: it is shown once and cannot be retrieved later.

A Merchant ID can carry several credentials, so you do not have to share one between systems.

**2. Check which environment the password is for.** The segment after `kco_` tells you:

```text
kco_<live|test>_api_<random>
```

`live` is a production credential and `test` is a playground one. They are not
interchangeable — a production credential returns `401 Unauthorized` against the playground
host and vice versa.

**3. Send them as HTTP Basic auth.** The API username is the Basic username and the API
password is the Basic password:

```http
Authorization: Basic base64(<API username>:<API password>)
```

Most HTTP clients build that header for you — with curl it is
`-u "$KUSTOM_API_USERNAME:$KUSTOM_API_PASSWORD"`.

**4. Point it at the right base URL.** Send production credentials to
`https://api.kustom.co/` and playground ones to `https://api.playground.kustom.co/`, as listed in
[Base URLs](#base-urls).

Use HTTPS for every request. The endpoints require TLS 1.2 and expect Server Name
Indication in the handshake, which every current HTTP client sends by default. Both
HTTP/1.1 and HTTP/2 are supported.

## Check that it works

Send a request to `https://api.playground.kustom.co` that needs authentication and nothing
else — reading an order id that does not exist is a good probe, because it distinguishes an
auth failure from a routing one:

```http
GET /checkout/v3/orders/does-not-exist
Authorization: Basic base64(<API username>:<API password>)
```

A `404 Not Found` means your credentials were accepted and the order simply is not there —
that is success. A `401 Unauthorized` means they are missing, malformed or belong to the other
environment.

## Why the same credentials go by several names

Older material, platform plugins and partner admin screens name the same two values
differently. Whatever the label, there are only ever two, and they map like this:

| You may see | It is |
| --- | --- |
| Username, Key ID, UID, or a Merchant ID field beside a password field | The API username |
| Password, shared secret, API secret, API key | The API password |

So "Merchant ID and shared secret" in an old guide is this same pair. A plugin field labeled
Merchant ID that sits next to a password field wants the API username, not your bare Merchant
ID.

One related point, because older samples and plugin configs still carry it: the API host
is **`api.kustom.co`**, and `api.playground.kustom.co` for the playground, exactly as in
[Base URLs](#base-urls). If you meet a different host in an old integration, replace it.

## Related

- [Checkout in 15 minutes](/checkout/quickstart/) — use the credentials to create a real order
- [Test data](/basics/test-data/) — the customer and payment details to use in the playground
- [How Kustom Checkout works](/basics/how-kustom-works/) — what the four calls are for
- [Create an order](/checkout/integrate/create-order/) — the first authenticated call in full
