curl -X POST "https://api.playground.try.be/shop/coupons/abc123/codes" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"code": "SUMMER2026",
"valid_from_date": "2026-06-01T00:00:00Z",
"valid_to_date": "2026-08-31T23:59:59Z",
"multi_use": false,
"customer_credit_id": "5f1234567890abcdef123456",
"customer_id": "11111111-1111-1111-1111-111111111111",
"revenue": 5000
}'
const response = await fetch('https://api.playground.try.be/shop/coupons/abc123/codes', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
"code": "SUMMER2026",
"valid_from_date": "2026-06-01T00:00:00Z",
"valid_to_date": "2026-08-31T23:59:59Z",
"multi_use": false,
"customer_credit_id": "5f1234567890abcdef123456",
"customer_id": "11111111-1111-1111-1111-111111111111",
"revenue": 5000
}),
})
if (!response.ok) {
throw new Error(`Trybe API ${response.status}: ${await response.text()}`)
}
const data = await response.json()
import httpx
response = httpx.post(
"https://api.playground.try.be/shop/coupons/abc123/codes",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
},
json={
"code": "SUMMER2026",
"valid_from_date": "2026-06-01T00:00:00Z",
"valid_to_date": "2026-08-31T23:59:59Z",
"multi_use": False,
"customer_credit_id": "5f1234567890abcdef123456",
"customer_id": "11111111-1111-1111-1111-111111111111",
"revenue": 5000
},
)
response.raise_for_status()
data = response.json()
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.playground.try.be/shop/coupons/abc123/codes', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'json' => [
'code' => 'SUMMER2026',
'valid_from_date' => '2026-06-01T00:00:00Z',
'valid_to_date' => '2026-08-31T23:59:59Z',
'multi_use' => false,
'customer_credit_id' => '5f1234567890abcdef123456',
'customer_id' => '11111111-1111-1111-1111-111111111111',
'revenue' => 5000
],
]);
$data = json_decode($response->getBody(), true);
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload, _ := json.Marshal(map[string]interface{}{
"code": "SUMMER2026",
"valid_from_date": "2026-06-01T00:00:00Z",
"valid_to_date": "2026-08-31T23:59:59Z",
"multi_use": false,
"customer_credit_id": "5f1234567890abcdef123456",
"customer_id": "11111111-1111-1111-1111-111111111111",
"revenue": 5000,
})
req, _ := http.NewRequest("POST", "https://api.playground.try.be/shop/coupons/abc123/codes", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
}