Required headers
Every API request must include both of these headers:| Header | Value | Description |
|---|---|---|
x-api-key | mk_live_... or mk_test_... | Your merchant API key |
x-maash-user-type | checkout | Identifies the request as a checkout API call |
API key authentication
Use API keys for all server-side API calls. Include your key in thex-api-key header.
Key formats
| Prefix | Environment | Description |
|---|---|---|
mk_live_ | Production | Processes real payments on mainnet |
mk_test_ | Test | Simulates payments without real funds |
Security best practices
Store keys securely
Store keys securely
Store API keys in environment variables or a secrets manager. Never hardcode
keys in source files.
Rotate keys regularly
Rotate keys regularly
Rotate keys periodically from the Maash Dashboard.
If a key is compromised, revoke it immediately and generate a new one.
Use test keys for development
Use test keys for development
Use test keys (
mk_test_) during development and staging. Only switch to
live keys (mk_live_) when deploying to production.Restrict access by IP
Restrict access by IP
Restrict API key access to specific IP addresses when possible to limit
exposure.
How keys are stored
API keys are hashed with SHA-256 before storage. Maash never stores your raw API key. If you lose your key, generate a new one from the dashboard.Session tokens
When you create a checkout session, the response includes acheckout_url_with_token that contains an embedded session token. This token authenticates requests from the hosted checkout page.
session_id and expire when the checkout session expires. You do not need to manage session tokens directly — the hosted checkout page handles this automatically.
Webhook signature verification
Maash signs every webhook delivery with HMAC-SHA256. Verify the signature to confirm that a webhook came from Maash and was not tampered with. See the Webhooks guide for implementation details.Authentication by endpoint
All endpoints require thex-api-key and x-maash-user-type: checkout headers.
| Endpoint | Method | Headers required |
|---|---|---|
GET /checkout/tokens | GET | x-api-key, x-maash-user-type: checkout |
GET /checkout/quote | GET | x-api-key, x-maash-user-type: checkout |
POST /checkout/sessions | POST | x-api-key, x-maash-user-type: checkout |
GET /checkout/sessions/{id} | GET | x-api-key, x-maash-user-type: checkout |
POST /checkout/sessions/select-payment | POST | x-api-key, x-maash-user-type: checkout |
Error responses
If authentication fails, the API returns one of these responses:401 Unauthorized (missing API key)
401 Unauthorized (missing user type)
403 Forbidden
Next steps
Quickstart
Create your first checkout session using your API key.
Webhooks
Learn how to verify webhook signatures with HMAC-SHA256.
Error handling
Handle authentication errors and other API error responses.
API Reference
See which endpoints require authentication.
