Skip to main content
The Partner API uses OAuth2 Client Credentials flow for authentication.

Getting Credentials

When you register as a partner, you receive:
CredentialDescription
client_idYour unique partner identifier
client_secretSecret key (keep secure!)
webhook_secretSecret for verifying webhooks

Getting an Access Token

curl -X POST https://api.acountpay.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET"

Response

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "payments:create payments:read"
}

Using the Token

Include the access token in all API requests:
curl -X POST https://api.acountpay.com/v1/partner/payments \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "X-Merchant-Client-Id: merchant_abc123" \
  -H "Content-Type: application/json" \
  -d '{"amount": 149.99, "referenceNumber": "ORDER-123"}'

Token Caching

Tokens are valid for 1 hour. Cache them to avoid unnecessary requests:
class AcountPayClient {
  constructor(clientId, clientSecret) {
    this.clientId = clientId;
    this.clientSecret = clientSecret;
    this.accessToken = null;
    this.tokenExpiry = null;
  }

  async getAccessToken() {
    if (this.accessToken && this.tokenExpiry > Date.now()) {
      return this.accessToken;
    }

    const response = await fetch('https://api.acountpay.com/oauth/token', {
      method: 'POST',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
      body: new URLSearchParams({
        grant_type: 'client_credentials',
        client_id: this.clientId,
        client_secret: this.clientSecret,
      }),
    });

    const data = await response.json();
    this.accessToken = data.access_token;
    this.tokenExpiry = Date.now() + (data.expires_in - 300) * 1000;
    return this.accessToken;
  }
}

Error Responses

StatusErrorDescription
400invalid_grantInvalid grant type
401invalid_clientInvalid credentials
429rate_limit_exceededToo many requests