Skip to main content

1. Overview

This tutorial provides technical guidance on extending your application's connection with GHTK delivery system in a simple, high-performance and secure manner.

1.1. Endpoint & Variables

These variables will be used in this API document.

VariablesDescriptionSTAGINGPRODUCTION
OPEN_APIOpen API serviceshttps://services-staging.ghtklab.comhttps://services.giaohangtietkiem.vn
CUSTOMER_WEBSITECustomer websitehttps://khachhang-staging.ghtklab.comhttps://khachhang.giaohangtietkiem.vn
VariablesDescription
API_TOKENThis API token key can be found on customer websites. These token could be located at CUSTOMER_WEBSITE/web/thong-tin-shop/tai-khoan
PARTNER_CODEShop code or Private partner code
MESSAGEAPI response message
ERROR_MESSAGEError message for failed request
LOG_IDLog ID for tracing

1.2. Token header

API Token Creation Guide

To create a new token, please click the Create Token button in the top right corner of the screen.

Enter information for your API_TOKEN:

  • Token Name: A memorable name for your integration service.

  • Expiration Date: The validity period of the token.

  • Select access permissions for the token (e.g., Create order, Calculate order fees, Get order status, etc.).

Use the API_TOKEN to authenticate requests with the OpenAPI system.

GET /services/authenticated HTTP/1.1
Host: {OPEN_API}
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}

1.3. Request format

GHTK API supports 2 content types: application/x-www-form-urlencoded and application/json.

  • API requests need to be in either x-www-form or json.
  • Default is application/x-www-form-urlencoded
  • Using api /services/authenticated to check the connection to the GHTK system.

application/x-www-form-urlencoded


POST /services/authenticated HTTP/1.1
Host: {OPEN_API}
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
Content-Type:application/x-www-form-urlencoded
field1=value1&field2=value2

application/json

POST /services/authenticated HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
Content-Type:application/x-www-form-urlencoded

{"field1":value1,"field2":value2}

1.4. Response format

Token verification failed:

HTTP/1.1 403 Forbidden Content-Type:application/json; charset=UTF-8 Content-Length: 0

Token verification succeeded

Content type: JSON

{
"success":true,
"message":"{MESSAGE}",
"log_id":"{LOG_ID}",
"data": ".."
}

Token verification succeeded but error occurred

Content type: JSON

{
"success": false,
"message": "{ERROR_MESSAGE}",
"error_code": "{ERROR_CODE}",
"log_id": "{LOG_ID}"
}