API Request
Creating a Payment Link
This documentation explains how to send a POST request to the https://api.yamt.com/Links endpoint using cURL in PHP. The request includes authentication via a Bearer Token and expects a JSON payload.
1. Endpoint Information
- Base URL: https://api.yamt.com
- Endpoint: /Links
- Method: POST
- Content-Type: application/json
- Authentication: Bearer Token (OAuth 2.0)
2. Required Headers
Each request must include the following headers:
Header Name | Description |
---|---|
Content-Type | Must be set to application/json to indicate JSON request body. |
Authorization | Must include a valid Bearer Token: Authorization: Bearer {token}. |
3. Request Parameters
The API expects a JSON object in the request body with the following parameters:
Parameter | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the transaction. |
amount | float | Yes | The amount to be processed. |
4. Authentication
- This API requires an Authorization Bearer Token for authentication.
- The token must be included in the request headers:
- Authorization: Bearer {your_token_here}
- You can generate an API token from your account dashboard in YAMT
5. Response Structure
Upon success, the API will return a JSON response. Below is an example of possible responses:
5.1 Success Response
{
"status": "success",
"redirect": "https://payment-processor.com/checkout/xyz"
}
Field | Type | Description |
---|---|---|
status | string | Indicates if the request was successful. |
redirect | string | URL to redirect the user for further processing.. |
6. Error Handling
If the API request encounters an issue, possible errors include:
Error | Type | Description |
---|---|---|
400 | Bad Request | The request is malformed or missing required fields. |
401 | Unauthorized | Invalid or missing API token. |
500 | Internal Server Error | A server-side error occurred. |
Recommended Action:
- Ensure id and amount are properly set.
- Verify that the Bearer Token is valid.
- Check for API downtime or contact support if issues persist.
Example PHP
<-?php
$url = "https://api.yamt.com/Links";
$data = [
"id" => STORE_ID,
"amount" => AMOUNT_IN_USDT
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . TOKEN_ACCESS
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo "cURL Error: " . curl_error($ch);
}
curl_close($ch);
$res = json_decode($response);
if ($res->redirect) {
header('Location: ' . $res->redirect);
exit;
} else {
echo $response;
exit;
}
Next: Feedback