Authentication
Every request to the Sotirea API carries an API key, sent as a bearer token:
GET /v1/me HTTP/1.1Host: api.sotirea.comAuthorization: Bearer sot_test_REPLACE_WITH_YOUR_KEYA request without a key, or with one that is malformed, revoked or expired, is answered 401
with the code unauthenticated; for a key that has expired, fields.rule says
api_key_expired. GET /v1/me is the simplest way to check a key: it answers
the key’s name, its organisation, whether that is Test or Live, and the permissions it holds.
Test keys and Live keys
Section titled “Test keys and Live keys”A key reaches exactly one organisation. A key starting sot_test_ reaches your Test
organisation, where every network is a test network. A key starting sot_live_ reaches your
Live organisation and real money. Your Test and Live organisations are separate: a Test key
can never see or move anything in Live, and the other way round.
The prefix is also there for secret scanners. A key ends in a short checksum, so a scanner can tell a real Sotirea key from a string that only looks like one, and a mistyped key is refused at once.
Creating a key
Section titled “Creating a key”Keys are created in the console, under Developers and API keys, by someone who can manage roles. A key holds roles, as a person does, and can do what those roles allow and nothing more. You can only give a key a role whose permissions you hold yourself.
For a key that runs an integration, the Integration role is the usual choice. It opens vaults, requests payments and manages webhooks, and it can see balances, payments, payment rules and the gas pool. Any role that can move money, Integration included, takes effect only once a second person who can manage roles confirms it. In an organisation where nobody else could confirm it, it takes effect at once.
Some things a key can never do, whatever its roles: it never approves a payment, and it never manages people or roles. Those stay with people, so that software alone cannot both ask for a payment and agree to it.
When you create a key you choose how long it works: 30 days, 90 days, a year, or until it is revoked.
What each permission allows
Section titled “What each permission allows”Each operation in the API reference needs one permission, and a key without it is
answered 403 with the code forbidden and the missing permission in fields.rule, such as
payments.request. GET /v1/me needs none.
Limiting a key to your servers
Section titled “Limiting a key to your servers”On a key’s page in the console, under Where it can be used from, you can list the
addresses your servers call from: single IP addresses or ranges in CIDR form, IPv4 or IPv6. A
request from anywhere else is answered 403, with fields.rule set to api_key_address. A
new key works from anywhere until you limit it.
If your servers have fixed outbound addresses, limit every Live key to them. A key that leaks is then useless anywhere else.
Replacing a key
Section titled “Replacing a key”To replace a key’s secret without stopping your integration, roll it from its page. You get a new secret at once and choose how long the old one keeps working: not at all, an hour, a day or a week. Deploy the new secret within that time and the old one stops on its own. Roll a key with no overlap at all if you think it has leaked, or revoke it.
Nobody can roll a key that can do something they cannot do themselves, because the new secret would let them do it.
Keeping keys safe
Section titled “Keeping keys safe”- Keep keys on your server. A browser or a phone app can be read by whoever holds it.
- Give each service its own key, named for it. Payments a key requests are shown under its name, so you can always tell which service asked.
- Give a key only the roles it needs. A service that only reads balances needs Viewer, not Integration.
- Use a Test key everywhere except the one place that handles real money.