Authentication

How to authenticate with the Anderro API using secret keys.

API keys

All API requests are authenticated using a secret key passed in the x-api-key header. There are three kinds, depending on how much one key should reach:

KeyPrefixReachesWhere to create it
Organization keysk_org_Every account in the organization, including accounts added laterOrganization → API keys
Account keysk_acct_Every product in one accountOrganization → API keys, or Settings → API keys in the account
Product keysk_One productThe product's Integration tab

Organization and account keys are meant for your own integrations, for example an affiliate dashboard inside your product (see Affiliate dashboards). You can create several, name them, and revoke one without affecting the others.

POSTAll /api/v1/* endpoints

Key format

Key typePrefixUsage
Organization keysk_org_Live server-side API calls for any product in the organization
Account keysk_acct_Live server-side API calls for any product in the account
Product Secret Keysk_Live server-side API calls for one product
Test Secret Keysk_test_Selects sandbox mode on tracking endpoints only

sk_test_ keys do not authenticate /api/v1 requests. Use your product's live secret key for the management API. Test keys only select sandbox on the tracking endpoints, including POST /events.

Security

A secret key reads, and unless it is read-only changes, your affiliate program. Never expose it in client-side code, Git repositories, or logs. Call the API from your server and send the browser only the data it should show.

Using your API key

Include the key in the x-api-key header with every request:

bash
curl -X POST https://anderro.com/api/v1/affiliates \
  -H "Content-Type: application/json" \
  -H "x-api-key: sk_your_secret_key" \
  -d '{"email": "[email protected]"}'

Organization and account keys

Owners and admins create these keys. An admin who is limited to some accounts can create keys for those accounts only.

  1. Open Organization → API keys (or Settings → API keys inside an account)
  2. Click Create key, name it, and choose what it works for, its access and an optional expiry
  3. Copy the key. It is shown once; Anderro stores only a hash of it

Access

AccessAllows
Read-onlyGET requests: affiliates, commissions, payouts, stats
Full accessEverything, including registering and removing affiliates, refunds, customer erasure and payout approval

A read-only key that sends anything other than GET receives 403 This API key is read-only.

Choosing the product

Most endpoints act on one product. A product key already is its product. An organization or account key says which one with the X-Anderro-Product header (or the product_id query parameter):

bash
curl https://anderro.com/api/v1/affiliates \
  -H "x-api-key: sk_acct_your_key" \
  -H "X-Anderro-Product: your_product_id"

GET /api/v1/products lists the product ids the key can reach. A key that reaches exactly one product may leave the header out. The stats endpoints can also total several products at once; see Get Stats.

Revoking

Click Revoke next to a key. Requests with it fail with 401 straight away. Keys also stop working when they expire, when their account is deactivated, or when the organization is deleted.

Finding your product key

  1. Log in to anderro.com
  2. Go to Products and select your SaaS product
  3. Open the Integration tab
  4. Your Secret Key is shown there - click to copy

Regenerating a product key

If your product key is compromised, you can regenerate it from the Integration tab. This immediately invalidates the old key - all requests using the old key will return 401.

Error responses

StatusErrorMeaning
401Missing x-api-key headerNo API key was provided
401Invalid API key formatKey doesn't start with sk_
401Invalid or revoked API keyKey doesn't match any active product, account or organization, or it was revoked or has expired
403This API key is read-onlyA read-only key sent a request that changes data
400This API key reaches several products…An organization or account key did not say which product to use
404Product not found for this API keyThe chosen product is outside the key's reach