# Get Access Token (Client Credentials)

Exchanges Client ID and Client Secret for an access token using OAuth 2.0 client credentials flow.
This endpoint implements server-side token caching to avoid exposing client secrets to frontend applications.
Tokens are automatically refreshed when near expiry.
**Environment URLs:**
- Sandbox: https://test.hs1api.com
- Production: https://prod.hs1api.com

**Note**: Sandbox and Production use different base URLs and credentials.

Endpoint: POST /oauth/client_credential/accesstoken
Version: 193.0.4
Security: bearerAuth, oAuthSandbox

## Query parameters:

  - `grant_type` (string, required)
    Must be "client_credentials"

## Request fields (application/x-www-form-urlencoded):

  - `client_id` (string, required)
    OAuth client ID provided by HS1 Support
    Example: YOUR_CLIENT_ID

  - `client_secret` (string, required)
    OAuth client secret provided by HS1 Support
    Example: YOUR_CLIENT_SECRET

## Request examples:

  - `Sandbox credentials example` (unknown)

## Response 200:

  - `200` (unknown)
    Token issued successfully

## Response 200 fields (application/json):

  - `access_token` (string)
    Bearer token for API authentication
    Example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

  - `token_type` (string)
    Token type (always "Bearer")
    Example: Bearer

  - `expires_in` (integer)
    Token lifetime in seconds
    Example: 3600

  - `scope` (string)
    Granted scopes (if requested)
    Example: publicapi.read publicapi.write

  - `organizationid` (string)
    Organization ID (if provided in request). Note lowercase 'd' is intentional for legacy API compatibility
    Example: 1006

## Response 400:

  - `400` (unknown)
    The request was invalid or cannot be processed

## Response 400 fields (application/json):

  - `error` (string)
    Example: invalid_request

  - `message` (string)
    Example: client_id and client_secret are required

## Response 401:

  - `401` (unknown)
    Authentication is required and has failed or has not been provided

## Response 401 fields (application/json):

  - `error` (string)
    Example: invalid_client

  - `message` (string)
    Example: Invalid client credentials

## Response 403:

  - `403` (unknown)
    The request is understood, but it has been refused or access is not allowed

## Response 404:

  - `404` (unknown)
    The requested resource is either missing or does not exist

## Response 408:

  - `408` (unknown)
    The server timed out while processing the request

## Response 429:

  - `429` (unknown)
    Rate limit exceeded

## Response 429 fields (application/json):

  - `error` (string)
    Example: rate_limit_exceeded

  - `message` (string)
    Example: Too many requests. Please try again later.

## Response 500:

  - `500` (unknown)
    An unexpected error occurred

## Response 500 fields (application/json):

  - `error` (string)
    Example: server_error

  - `message` (string)
    Example: An unexpected error occurred

## Response 502:

  - `502` (unknown)
    Upstream token service unavailable

## Response 502 fields (application/json):

  - `error` (string)
    Example: upstream_error

  - `message` (string)
    Example: Token service unavailable

## Response 200 examples:

  - `Successful token response` (unknown)

