> For the complete documentation index, see [llms.txt](https://docs.spacecoin.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spacecoin.org/do-not-open/api-key-authentication.md).

# API-Key Authentication

### Step 1 — Get an API key

1. Visit the [billing portal](https://coordination.spacerouter.org/billing).
2. Sign in with your email and pick a plan.
3. Copy the `sr_live_…` key shown on screen. Treat it like a password.

Lost your key? You can rotate it at any time at [/billing/reissue](https://coordination.spacerouter.org/billing/reissue). Your existing key stops working as soon as you reissue.

### Step 2 — Send a request

#### HTTP proxy (port 8080)

```bash
curl -x "http://gateway.spacerouter.org:8080" \
     -U "sr_live_YOUR_API_KEY:" \
     https://httpbin.org/ip
```

#### SOCKS5 proxy (port 1080)

```bash
curl -x "socks5://sr_live_YOUR_API_KEY:@gateway.spacerouter.org:1080" \
     https://httpbin.org/ip
```

### Geo targeting

Append routing parameters to the username segment of the URL. Order doesn't matter; pairs are separated by hyphens.

```
socks5://sr_live_YOUR_API_KEY-country-KR-type-residential:@gateway.spacerouter.org:1080
```

| Parameter | Values                                         | Example                    |
| --------- | ---------------------------------------------- | -------------------------- |
| `country` | 2-letter ISO country code                      | `country-US`, `country-KR` |
| `type`    | `residential`, `mobile`, `business`, `hosting` | `type-residential`         |

### Endpoints

| Protocol | Host                      | Port   |
| -------- | ------------------------- | ------ |
| HTTP     | `gateway.spacerouter.org` | `8080` |
| SOCKS5   | `gateway.spacerouter.org` | `1080` |

### Common errors

| HTTP code | Meaning                                      | What to do                                                                           |
| --------- | -------------------------------------------- | ------------------------------------------------------------------------------------ |
| **407**   | Bad or missing API key.                      | Double-check the key, especially the trailing colon in `sr_live_KEY:` for `curl -U`. |
| **402**   | Monthly data quota exceeded.                 | Upgrade your plan in the billing portal.                                             |
| **429**   | Rate limited.                                | Slow down. The response includes a `Retry-After` header.                             |
| **503**   | No Provider matches your region/type filter. | Drop the filter or pick another region.                                              |

For the full error catalogue, see Errors & Troubleshooting.

### Use it in your code

Most users will use the SDK rather than raw `curl`:

**Python SDK** — `SpaceRouter("sr_live_…")` — full HTTP method coverage, retries, async client.

**JavaScript SDK** — `new SpaceRouter("sr_live_…")` — fetch-style API, TypeScript types.
