Grant credit
curl --request POST \
--url https://api.togai.com/credits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"creditRequests": [
{
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2023-02-04",
"effectiveUntil": "2024-02-04",
"creditAmount": 1000,
"priority": 1
}
]
}
'import requests
url = "https://api.togai.com/credits"
payload = { "creditRequests": [
{
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2023-02-04",
"effectiveUntil": "2024-02-04",
"creditAmount": 1000,
"priority": 1
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
creditRequests: [
{
accountId: 'ACC001',
purpose: 'Prepaid Credit',
effectiveFrom: '2023-02-04',
effectiveUntil: '2024-02-04',
creditAmount: 1000,
priority: 1
}
]
})
};
fetch('https://api.togai.com/credits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.togai.com/credits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'creditRequests' => [
[
'accountId' => 'ACC001',
'purpose' => 'Prepaid Credit',
'effectiveFrom' => '2023-02-04',
'effectiveUntil' => '2024-02-04',
'creditAmount' => 1000,
'priority' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.togai.com/credits"
payload := strings.NewReader("{\n \"creditRequests\": [\n {\n \"accountId\": \"ACC001\",\n \"purpose\": \"Prepaid Credit\",\n \"effectiveFrom\": \"2023-02-04\",\n \"effectiveUntil\": \"2024-02-04\",\n \"creditAmount\": 1000,\n \"priority\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.togai.com/credits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"creditRequests\": [\n {\n \"accountId\": \"ACC001\",\n \"purpose\": \"Prepaid Credit\",\n \"effectiveFrom\": \"2023-02-04\",\n \"effectiveUntil\": \"2024-02-04\",\n \"creditAmount\": 1000,\n \"priority\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/credits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"creditRequests\": [\n {\n \"accountId\": \"ACC001\",\n \"purpose\": \"Prepaid Credit\",\n \"effectiveFrom\": \"2023-02-04\",\n \"effectiveUntil\": \"2024-02-04\",\n \"creditAmount\": 1000,\n \"priority\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": "creds.1znQx9jiIXw.r44fc",
"customerId": "7VcRw9xZDIqsC5E",
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2020-07-04",
"effectiveUntil": "2021-07-04",
"status": "ACTIVE",
"creditAmount": 1000,
"creditUnit": "USD",
"holdAmount": 500,
"consumedAmount": 400,
"priority": 1,
"createdAt": "2020-07-04T12:00:00.000Z"
},
{
"id": "creds.1znQ46jiIXw.r24fc",
"customerId": "7VcRw9xZDIqsC5E",
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2020-08-04",
"effectiveUntil": "2021-08-04",
"status": "ACTIVE",
"creditAmount": 1000,
"creditUnit": "USD",
"holdAmount": 500,
"consumedAmount": 400,
"priority": 1,
"createdAt": "2020-08-04T12:00:00.000Z"
}
]{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}Credits
Grant credit
Grant credit
POST
/
credits
Grant credit
curl --request POST \
--url https://api.togai.com/credits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"creditRequests": [
{
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2023-02-04",
"effectiveUntil": "2024-02-04",
"creditAmount": 1000,
"priority": 1
}
]
}
'import requests
url = "https://api.togai.com/credits"
payload = { "creditRequests": [
{
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2023-02-04",
"effectiveUntil": "2024-02-04",
"creditAmount": 1000,
"priority": 1
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
creditRequests: [
{
accountId: 'ACC001',
purpose: 'Prepaid Credit',
effectiveFrom: '2023-02-04',
effectiveUntil: '2024-02-04',
creditAmount: 1000,
priority: 1
}
]
})
};
fetch('https://api.togai.com/credits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.togai.com/credits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'creditRequests' => [
[
'accountId' => 'ACC001',
'purpose' => 'Prepaid Credit',
'effectiveFrom' => '2023-02-04',
'effectiveUntil' => '2024-02-04',
'creditAmount' => 1000,
'priority' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.togai.com/credits"
payload := strings.NewReader("{\n \"creditRequests\": [\n {\n \"accountId\": \"ACC001\",\n \"purpose\": \"Prepaid Credit\",\n \"effectiveFrom\": \"2023-02-04\",\n \"effectiveUntil\": \"2024-02-04\",\n \"creditAmount\": 1000,\n \"priority\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.togai.com/credits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"creditRequests\": [\n {\n \"accountId\": \"ACC001\",\n \"purpose\": \"Prepaid Credit\",\n \"effectiveFrom\": \"2023-02-04\",\n \"effectiveUntil\": \"2024-02-04\",\n \"creditAmount\": 1000,\n \"priority\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/credits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"creditRequests\": [\n {\n \"accountId\": \"ACC001\",\n \"purpose\": \"Prepaid Credit\",\n \"effectiveFrom\": \"2023-02-04\",\n \"effectiveUntil\": \"2024-02-04\",\n \"creditAmount\": 1000,\n \"priority\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": "creds.1znQx9jiIXw.r44fc",
"customerId": "7VcRw9xZDIqsC5E",
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2020-07-04",
"effectiveUntil": "2021-07-04",
"status": "ACTIVE",
"creditAmount": 1000,
"creditUnit": "USD",
"holdAmount": 500,
"consumedAmount": 400,
"priority": 1,
"createdAt": "2020-07-04T12:00:00.000Z"
},
{
"id": "creds.1znQ46jiIXw.r24fc",
"customerId": "7VcRw9xZDIqsC5E",
"accountId": "ACC001",
"purpose": "Prepaid Credit",
"effectiveFrom": "2020-08-04",
"effectiveUntil": "2021-08-04",
"status": "ACTIVE",
"creditAmount": 1000,
"creditUnit": "USD",
"holdAmount": 500,
"consumedAmount": 400,
"priority": 1,
"createdAt": "2020-08-04T12:00:00.000Z"
}
]{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Payload to grant credits
payload to create credits
Show child attributes
Show child attributes
Response
Response for List credits request
Show child attributes
Show child attributes
⌘I
