Skip to main content

Authentication

The NowPost API uses Bearer token authentication. You need to obtain a token before making API requests.

Getting Your API Token

Generate a token using your partner credentials:

curl -X POST "https://api.nowpost.com/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "your-email@example.com",
"password": "your-password"
}'

Response:

{
"success": true,
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresAt": "2024-01-15T12:00:00Z",
"user": {
"id": "user_123",
"email": "your-email@example.com"
}
}
}

Using Your Token

Include the token in the Authorization header for all API requests:

curl -X GET "https://api.nowpost.com/api/v1/orders" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"

Token Refresh

Tokens expire after 24 hours. Refresh before expiry:

curl -X POST "https://api.nowpost.com/api/v1/auth/refresh" \
-H "Authorization: Bearer YOUR_CURRENT_TOKEN"

Authentication Errors

Status CodeErrorSolution
401Invalid or missing tokenCheck your token is correct and not expired
403Insufficient permissionsYour account may not have access to this endpoint
429Rate limitedSlow down requests, max 100/minute

Security Best Practices

  1. Never expose tokens in client-side code - Keep tokens server-side
  2. Use environment variables - Don't hardcode tokens
  3. Rotate tokens regularly - Refresh before expiry
  4. Use HTTPS only - Never send tokens over HTTP