Products API
The Products API allows you to create and manage products that can be associated with plans, payment links, and checkout sessions.
Base URL
https://api.4geeks.io
Authentication¶
All endpoints require the X-Api-Key header:
See Authentication for details.
Create Product¶
Creates a new product.
Request Body¶
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Product name |
| description | string | No | Product description |
| active | boolean | No | Whether the product is active. Default: true |
Request Example¶
const response = await fetch('https://api.4geeks.io/v1/products', {
method: 'POST',
headers: {
'X-Api-Key': 'sk_test_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Premium Plan',
description: 'Monthly premium subscription with all features',
active: true
})
});
const data = await response.json();
console.log(data);
Response (200 OK)¶
| Field | Type | Description |
|---|---|---|
| id | string | Product ID |
| object | string | Object type (default: “product”) |
| name | string | Product name |
| description | string | Product description |
| active | boolean | Whether the product is active |
Response Example¶
{
"id": "prod_a1b2c3d4e5f6",
"object": "product",
"name": "Premium Plan",
"description": "Monthly premium subscription with all features",
"active": true
}
List Products¶
Lists products with pagination.
Query Parameters¶
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| limit | integer | No | 10 | Number of results per page |
| offset | integer | No | 0 | Number of results to skip |
Request Example¶
Response (200 OK)¶
| Field | Type | Description |
|---|---|---|
| items | array[ProductResponse] | Array of product objects |
| total_items | integer | Total number of products |
| limit | integer | Requested page size |
| offset | integer | Requested offset |
Response Example¶
{
"items": [
{
"id": "prod_a1b2c3d4e5f6",
"object": "product",
"name": "Premium Plan",
"description": "Monthly premium subscription with all features",
"active": true
},
{
"id": "prod_g7h8i9j0k1l2",
"object": "product",
"name": "Basic Plan",
"description": null,
"active": true
}
],
"total_items": 2,
"limit": 5,
"offset": 0
}
Error Response (422 Validation Error)¶
All endpoints may return a 422 status when validation fails.
{
"detail": [
{
"loc": ["body", "name"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
Still questions? Ask the community or explore tutorials