You can communicate with Midtrans API by sending HTTP(S) request. The request consists of Base URL and HTTP(S) Header. The Base URL specifies the resource to which the request is applied. The HTTP(S) Header carries the data type of the request, data type of the response, and the authentication information. Midtrans then sends a response back in JSON format.
API Base URL
The Base URLs are as given below.
- Sandbox Environment:
https://api.sandbox.midtrans.com
- Production Environment:
https://api.midtrans.com
Note
In the Sandbox Environment, the transactions will not trigger actual purchase. Midtrans service can be fully utilized in the Production Environment.
HTTP(S) Header
An HTTP Header is used in an HTTP request to provide information about the request. The HTTP Header for Midtrans API request carries the following information.
Header | Value | Definition |
---|---|---|
Content-Type | application/json | Indicates data type of the request. |
Accept | application/json | Indicates the expected data type of the response. |
Authorization | Basic base64(server key , : ) | Contains the credentials to authenticate a user. Midtrans uses Basic AUTH for authentication. For more details, refer Authorization |
Content-Type and Accept Header
The input and output parameters for Midtrans API are in JSON format.
To accept JSON input and output parameters, you need to add the following HTTP(S) Header.
Content-Type: application/json
Accept: application/json
Note
Maximum allowed size of HTTP(S) request is 16KB. Please limit the size of your HTTP requests to this value to avoid request failures.