curl --request POST \
--url https://api.kawan.digital/v1/orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"buyer": {
"name": "Budi",
"email": "budi@example.com",
"phone": "081234567890"
},
"items": [
{
"type": "product",
"product_id": "11111111-1111-4111-8111-111111111111"
}
],
"payment_method": "duitku:qris",
"success_url": "https://example.com/thanks",
"attribution": {
"utm_source": "crm"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
buyer: {name: 'Budi', email: 'budi@example.com', phone: '081234567890'},
items: [{type: 'product', product_id: '11111111-1111-4111-8111-111111111111'}],
payment_method: 'duitku:qris',
success_url: 'https://example.com/thanks',
attribution: {utm_source: 'crm'}
})
};
fetch('https://api.kawan.digital/v1/orders', 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.kawan.digital/v1/orders",
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([
'buyer' => [
'name' => 'Budi',
'email' => 'budi@example.com',
'phone' => '081234567890'
],
'items' => [
[
'type' => 'product',
'product_id' => '11111111-1111-4111-8111-111111111111'
]
],
'payment_method' => 'duitku:qris',
'success_url' => 'https://example.com/thanks',
'attribution' => [
'utm_source' => 'crm'
]
]),
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;
}{
"success": true,
"data": {
"order": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"payment_reference": "<string>",
"amount": 123,
"subtotal": 123,
"currency": "IDR",
"settlement_channel": "<string>",
"payment_provider": "<string>",
"payment_method": "<string>",
"buyer": {
"name": "<string>",
"email": "jsmith@example.com",
"phone": "<string>"
},
"items": [
{
"type": "product",
"title": "<string>",
"quantity": 123,
"unit_price": 123,
"line_total": 123,
"product_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"bundle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"checkout_url": "<string>",
"payment_url": "<string>",
"requires_payment": true
},
"payment": {
"kind": "none",
"amount": 123,
"currency": "IDR",
"checkout_url": "<string>",
"payment_url": "<string>",
"provider": "<string>",
"method": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"seller_bank": {
"bank_name": "<string>",
"bank_code": "<string>",
"account_number": "<string>",
"account_holder": "<string>",
"payment_reference": "<string>",
"unique_amount_code": 123,
"transfer_amount": 123
},
"snap": {
"token": "<string>",
"client_key": "<string>",
"snap_script_url": "<string>"
}
},
"redirect": {
"success_url": "<string>",
"return_url": "<string>",
"error_url": "<string>"
},
"duplicate_pending": true
}
}{
"success": true,
"data": {
"order": {
"id": "11111111-1111-4111-8111-111111111111",
"status": "pending",
"amount": 99000,
"currency": "IDR",
"requires_payment": true,
"checkout_url": "https://toko.linkdigital.id/checkout/pay/11111111-1111-4111-8111-111111111111",
"payment_url": "https://app.duitku.com/redirect/abc123"
},
"payment": {
"kind": "gateway",
"provider": "duitku",
"amount": 99000,
"currency": "IDR",
"checkout_url": "https://toko.linkdigital.id/checkout/pay/11111111-1111-4111-8111-111111111111",
"payment_url": "https://app.duitku.com/redirect/abc123",
"seller_bank": null,
"snap": null
},
"redirect": {
"success_url": "https://example.com/thanks?order=11111111-1111-4111-8111-111111111111",
"return_url": "https://toko.linkdigital.id/checkout/success/11111111-1111-4111-8111-111111111111?result=pending",
"error_url": "https://toko.linkdigital.id/checkout/success/11111111-1111-4111-8111-111111111111?result=error"
}
}
}{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Invalid JSON body."
}
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid Authorization header."
}
}{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Rate limit exceeded."
}
}Create a checkout order
Creates a store order and starts the payment session when needed.
Send Idempotency-Key (any unique string, stored 24 hours per API key)
so retries replay the original response.
A pending order for the same buyer + cart returns HTTP 200 with
duplicate_pending: true and the existing order.
Response includes payment JSON (for a custom UI), a direct gateway
payment_url when the provider has a hosted invoice, and redirect
URLs for after payment.
Optional success_url is where the buyer is sent after the order is
actually paid (Kawan appends ?order={id}). Gateway return may still
be unpaid — treat webhook order.paid as the source of truth.
curl --request POST \
--url https://api.kawan.digital/v1/orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"buyer": {
"name": "Budi",
"email": "budi@example.com",
"phone": "081234567890"
},
"items": [
{
"type": "product",
"product_id": "11111111-1111-4111-8111-111111111111"
}
],
"payment_method": "duitku:qris",
"success_url": "https://example.com/thanks",
"attribution": {
"utm_source": "crm"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
buyer: {name: 'Budi', email: 'budi@example.com', phone: '081234567890'},
items: [{type: 'product', product_id: '11111111-1111-4111-8111-111111111111'}],
payment_method: 'duitku:qris',
success_url: 'https://example.com/thanks',
attribution: {utm_source: 'crm'}
})
};
fetch('https://api.kawan.digital/v1/orders', 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.kawan.digital/v1/orders",
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([
'buyer' => [
'name' => 'Budi',
'email' => 'budi@example.com',
'phone' => '081234567890'
],
'items' => [
[
'type' => 'product',
'product_id' => '11111111-1111-4111-8111-111111111111'
]
],
'payment_method' => 'duitku:qris',
'success_url' => 'https://example.com/thanks',
'attribution' => [
'utm_source' => 'crm'
]
]),
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;
}{
"success": true,
"data": {
"order": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"payment_reference": "<string>",
"amount": 123,
"subtotal": 123,
"currency": "IDR",
"settlement_channel": "<string>",
"payment_provider": "<string>",
"payment_method": "<string>",
"buyer": {
"name": "<string>",
"email": "jsmith@example.com",
"phone": "<string>"
},
"items": [
{
"type": "product",
"title": "<string>",
"quantity": 123,
"unit_price": 123,
"line_total": 123,
"product_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"bundle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"checkout_url": "<string>",
"payment_url": "<string>",
"requires_payment": true
},
"payment": {
"kind": "none",
"amount": 123,
"currency": "IDR",
"checkout_url": "<string>",
"payment_url": "<string>",
"provider": "<string>",
"method": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"seller_bank": {
"bank_name": "<string>",
"bank_code": "<string>",
"account_number": "<string>",
"account_holder": "<string>",
"payment_reference": "<string>",
"unique_amount_code": 123,
"transfer_amount": 123
},
"snap": {
"token": "<string>",
"client_key": "<string>",
"snap_script_url": "<string>"
}
},
"redirect": {
"success_url": "<string>",
"return_url": "<string>",
"error_url": "<string>"
},
"duplicate_pending": true
}
}{
"success": true,
"data": {
"order": {
"id": "11111111-1111-4111-8111-111111111111",
"status": "pending",
"amount": 99000,
"currency": "IDR",
"requires_payment": true,
"checkout_url": "https://toko.linkdigital.id/checkout/pay/11111111-1111-4111-8111-111111111111",
"payment_url": "https://app.duitku.com/redirect/abc123"
},
"payment": {
"kind": "gateway",
"provider": "duitku",
"amount": 99000,
"currency": "IDR",
"checkout_url": "https://toko.linkdigital.id/checkout/pay/11111111-1111-4111-8111-111111111111",
"payment_url": "https://app.duitku.com/redirect/abc123",
"seller_bank": null,
"snap": null
},
"redirect": {
"success_url": "https://example.com/thanks?order=11111111-1111-4111-8111-111111111111",
"return_url": "https://toko.linkdigital.id/checkout/success/11111111-1111-4111-8111-111111111111?result=pending",
"error_url": "https://toko.linkdigital.id/checkout/success/11111111-1111-4111-8111-111111111111?result=error"
}
}
}{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Invalid JSON body."
}
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid Authorization header."
}
}{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Rate limit exceeded."
}
}Authorizations
API key from Dashboard → Developer API. Shown once when created.
Headers
Unique key to make create-order safe to retry.
Body
Show child attributes
Show child attributes
1Show child attributes
Show child attributes
HTTPS URL to send the buyer after the order is paid. http is only
allowed for localhost. Kawan appends ?order={id}.
Show child attributes
Show child attributes