Authentication
The Cyan API is a JSON API with three endpoints. Every request is authenticated with your API key.
Base URL
Section titled “Base URL”https://api.cyan.cash/v1The /v1 in the path is the version. Changes to it only ever add things, so your integration keeps working.
Your API key
Section titled “Your API key”Send your key as a bearer token on every request:
const response = await fetch( "https://api.cyan.cash/v1/payment-links/pl_019d0a1b2c3d4e5f60718293a4b5c6d7", { headers: { Authorization: `Bearer ${process.env.CYAN_API_KEY}` } },);Get a key
Section titled “Get a key”Create your key in the Cyan app under API keys. You’ll need to connect your Stripe account first, and be an admin of the business.
The key is shown once, when you create it. Store it in your server’s environment or a secrets manager.
Each business has one key. If you lose it, or think it has leaked, select Regenerate on the same page. The old key stops working immediately, so update your server right away.
Keep it on your server
Section titled “Keep it on your server”Your API key can create payments for your business, so treat it like a password:
- Call the API only from your backend.
- Never put the key in a web page, a mobile app or a public repository.
Your chat page doesn’t need the key. It receives a payment link’s url from your server, and the customer pays inside Cyan’s checkout.
Test keys
Section titled “Test keys”A key that starts with cyan_test_ is a test key. Its payments run in Stripe’s sandbox and move no money. See Test your integration.
When authentication fails
Section titled “When authentication fails”| Status | code |
What to do |
|---|---|---|
401 |
api_key_missing |
Send the Authorization header. |
401 |
invalid_api_key |
Check the key. If you regenerated it, use the new one. |
403 |
provider_not_connected |
Your key works, but your Stripe account isn’t connected. Connect it in the app under Settings → Connectors. |
See Errors for every error code.