This page is meant for developers, vendors, and IT administrators to understand how to generate the bearer token to access our API to get/create/update shortlinks.
Bearer Token & API Key Generation
Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. GoGovKH uses bearer authentication.
To generate the token, click on "API Integration" in the navigation bar. From there, click on Generate API key and copy the token. Use this key to start using GoGovKH's API.
Keep the bearer tokensafe: You should not share the bearer token with anyone. Use services like 1Password to store it.
Authentication
GoGovKH's API uses APIKey for authentication. User can view and manage API Keys in Go API Dashboard.
Staging secret keys will have test_v1_version prefix.
Production secret keys will have live_v1_version prefix.
Authentication to the API is performed via bearer auth.
curl --location --request POST 'https://go.gov.kh/api/v1/urls' \--header 'Authorization: Bearer live_v1_YOUR_API_KEY'
All API requests must be made over HTTPS. Calls made over plain HTTP will fail and requests without authentication will also fail.
Errors
Go API uses conventional API Error to indicate the success or failure of an API request.
Status Codes
Description
200 - OK
Everything worked as expected.
400 - Bad Request
The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized
No valid API key provided.
402 - Request Failed
The parameters were valid but the request failed.
404 - Not Found
The requested resource doesn't exist.
429 - Too Many Requests
Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.
500, 502, 503, 504 - Server Errors
Something went wrong on GoGovKH's API end.
Rate Limits
For all of GoGovKH's APIs, GoGovKH allows up to 100 requests per second (Subject to change).