Skip to content

Products API

🤖 Explain with AI

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:

X-Api-Key: sk_test_your_api_key_here

See Authentication for details.


Create Product

Creates a new product.

POST /v1/products

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

curl -X POST 'https://api.4geeks.io/v1/products' \
  -H 'X-Api-Key: sk_test_your_api_key_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Premium Plan",
    "description": "Monthly premium subscription with all features",
    "active": true
  }'
import requests

response = requests.post(
    'https://api.4geeks.io/v1/products',
    headers={'X-Api-Key': 'sk_test_your_api_key_here'},
    json={
        'name': 'Premium Plan',
        'description': 'Monthly premium subscription with all features',
        'active': True
    }
)
print(response.json())
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.

GET /v1/products

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

curl -X GET 'https://api.4geeks.io/v1/products?limit=5&offset=0' \
  -H 'X-Api-Key: sk_test_your_api_key_here'
import requests

response = requests.get(
    'https://api.4geeks.io/v1/products',
    headers={'X-Api-Key': 'sk_test_your_api_key_here'},
    params={'limit': 5, 'offset': 0}
)
print(response.json())
const response = await fetch('https://api.4geeks.io/v1/products?limit=5&offset=0', {
    headers: {'X-Api-Key': 'sk_test_your_api_key_here'}
});
const data = await response.json();
console.log(data);

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