Authentication

Secure your API requests with proper authentication

Authentication Methods

NexaPay API uses API keys to authenticate requests. All API requests must include a valid API key in the Authorization header.

API Key Types

Secret Key

Full access to all API endpoints. Use for server-side applications only.

nxpos_live_sk_...

Publishable Key

Limited access for client-side applications. Safe to expose in frontend code.

nxpos_live_pk_...

Authorization Header

Include your API key in the Authorization header as a Bearer token:

Authorization: Bearer nxpos_live_sk_xxxxxxxxxxxxxxxxxxxxxxxx

Example Request

curl -X GET "https://api.nexapay.com/v1/products" \
  -H "Authorization: Bearer nxpos_live_sk_your_key_here" \
  -H "Content-Type: application/json"

Token Expiration

API Keys

Do not expire unless manually revoked

Access Tokens

Expire after 24 hours, refresh tokens valid for 30 days

OAuth 2.0 Flow

For third-party applications, use OAuth 2.0 for secure user authorization:

// Step 1: Redirect user to authorization URL
GET https://auth.nexapay.com/oauth/authorize?
  response_type=code&
  client_id=YOUR_CLIENT_ID&
  redirect_uri=https://your-app.com/callback&
  scope=read_products,write_orders

// Step 2: Exchange code for tokens
POST https://auth.nexapay.com/oauth/token
{
  "grant_type": "authorization_code",
  "code": "AUTHORIZATION_CODE",
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "redirect_uri": "https://your-app.com/callback"
}

// Step 3: Use access token
Authorization: Bearer ACCESS_TOKEN

Available Scopes

ScopeDescription
read_productsRead product and category information
write_productsCreate, update, and delete products
read_ordersRead order information
write_ordersCreate and update orders
read_customersRead customer information
write_customersCreate and update customers
read_inventoryRead inventory levels
write_inventoryUpdate inventory levels
read_reportsAccess business reports and analytics
manage_storesManage store settings
manage_staffManage staff accounts

Security Best Practices

Never expose secret keys in client-side code
Use environment variables to store API keys
Rotate keys periodically (recommended: every 90 days)
Use webhooks instead of polling when possible
Implement IP whitelisting for production environments
Monitor API usage for suspicious activity

Authentication Errors

{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or expired API key",
    "request_id": "req_abc123xyz"
  }
}