# Userstack: agents start here

Steps for AI coding agents that add Userstack to a project.

## 1. Get an API key

A person creates the account: an agent cannot sign up. Sign up at https://app.apilayer.com/signup/userstack/free?utm_source=productpage_userstack&utm_medium=internal and subscribe to Userstack. The Free plan includes 100 requests / month and needs no credit card.

Copy the API key from the APILayer dashboard and give it to the agent as an environment variable (step 2).

## 2. Keep the key out of code

Read the key from an environment variable named `APILAYER_ACCESS_KEY`. Do not write the key into source code, commit it to git, or paste it into a chat.

Call Userstack from server code. The key travels in the request URL, so a request sent from a browser shows the key to every visitor.

```
# add .env to .gitignore
APILAYER_ACCESS_KEY=your_api_key
```

## 3. Make the first request

- Base URL: `http://api.userstack.com`
- Auth: `access_key` query parameter
- Formats: JSON, XML
- Endpoints:
  - `/detect` Detect

```sh
curl "http://api.userstack.com/detect?access_key=$APILAYER_ACCESS_KEY&ua=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_14_0)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36"
```

## 4. Check the plan before you use a feature

Each plan adds features to the plan before it. Check that the account's plan includes a feature before writing code that uses it.

| Plan | Requests / month | Adds |
|---|---|---|
| Free | 100 | Device Detection, Browser Detection, OS Detection, HTTPS Encryption |
| Starter | 50,000 | Crawler Detection, Standard Support |
| Professional | 500,000 | Bulk Lookups |
| Enterprise | 2,000,000 | Same features as Professional |

Prices: https://apilayer.com/products/userstack/#pricing

## 5. Use the machine-readable docs

- Userstack documentation: https://docs.apilayer.com/apilayer/docs/userstack?utm_source=productpage_userstack&utm_medium=internal
- APILayer llms.txt: https://apilayer.com/llms.txt
