SiteSwapDevelopers
Get started

Authentication

Every call carries an API key or a sign-in token in a header.

Every endpoint except the OpenAPI spec and signing in needs a key. Send it one of two ways:

curl -H "Authorization: Bearer ssk_YOUR_KEY" https://dev.siteswap.pro/api/v1/company
curl -H "X-API-Key: ssk_YOUR_KEY" https://dev.siteswap.pro/api/v1/company

Who a key acts for

A key belongs to one company and acts as the owner or admin who asked for it. Everything that person may not do, the key may not do either, and these stop a key at once:

  • the person leaves the company, is no longer an owner or admin, is suspended or deletes their account (403 account_unavailable);
  • the company is suspended or closed;
  • SiteSwap publishes new Terms and the person has not accepted them yet (403 terms_required). The key works again as soon as they accept on the site.

Keeping a key safe

  • Call the API from your server. There is no CORS: browsers on other sites cannot call it, and a key in a web page can be read by anyone who opens it.
  • SiteSwap keeps only a SHA-256 fingerprint of each key and compares it in constant time. Nobody at SiteSwap can read a key back.
  • Revoke a key the moment it may have leaked, on API keys, or from anywhere by sending the key itself:
curl -X DELETE -H "Authorization: Bearer ssk_YOUR_KEY" https://dev.siteswap.pro/api/v1/keys/self

A revoked key stops at once, on every server.

Scopes

A key asks for what it may do, and a SiteSwap admin grants some or all of it. A call outside the key's scopes answers 403 scope_missing.

ScopeWhat it allows
listings:read (Read listings)Search and read listings, company profiles and the product catalog.
listings:write (Manage own listings and stock)Post, change, pause and close your company's listings, add photos and update stock.
offers (Offers)Read your company's offers, send offers and counteroffers, accept, decline and withdraw.
alerts (Alerts)Read and manage the saved searches and notifications of the person who asked for the key.
(any key)GET /company, GET /keys and revoking keys

Phone apps

The phone apps sign a person in with their email and password and get a sign-in token instead of a key. See Using the API from the phone app.

SiteSwap API v1Support