Skip to main content
The Pocketsflow HTTP API allows you to programmatically manage your products, orders, customers, discounts, upsells, and more using API keys.

Authentication

All API endpoints require authentication using API keys. You can generate API keys from your Pocketsflow dashboard under Settings > API Keys.

API Key Format

  • Live mode: pk_live_...
  • Test mode: pk_test_...

Using API Keys

Include your API key in the Authorization header:
curl -X GET "https://api.pocketsflow.com/products" \
  -H "Authorization: Bearer pk_live_your_api_key_here"
Alternatively, you can also use JWT tokens from Auth0 for authentication.

Products

List all products

GET /products
Returns all products for the authenticated user. Response:
[
  {
    "_id": "65abc123...",
    "name": "My Digital Product",
    "price": 29.99,
    "published": true,
    "createdAt": "2024-01-15T10:30:00Z"
  }
]

Get a product

GET /products/:id
Returns a single product by ID.

Create a product

POST /products
Request body:
{
  "name": "New Product",
  "price": 49.99,
  "description": "Product description"
}

Update a product

POST /products/update/:id
Request body:
{
  "name": "Updated Product Name",
  "price": 59.99
}

Delete a product

DELETE /products/:id

Product Variants

Create a variant

POST /products/variants
Request body:
{
  "productId": "65abc123...",
  "name": "Premium Version",
  "price": 79.99
}

Delete a variant

DELETE /products/variants/:id

Orders

List orders

GET /orders
Query parameters:
ParameterTypeDescription
startDatestringFilter orders from this date (ISO 8601)
endDatestringFilter orders until this date (ISO 8601)
productIdstringFilter by product ID
pagenumberPage number (default: 1)
pageSizenumberItems per page (default: 20)
Example:
curl -X GET "https://api.pocketsflow.com/orders?page=1&pageSize=10" \
  -H "Authorization: Bearer pk_live_your_api_key"
Response:
{
  "orders": [
    {
      "_id": "65xyz789...",
      "buyerEmail": "customer@example.com",
      "gross": 49.99,
      "net": 45.99,
      "taxes": 0,
      "createdAt": "2024-01-20T14:30:00Z",
      "product": {
        "_id": "65abc123...",
        "name": "My Product"
      }
    }
  ],
  "pagination": {
    "totalCount": 150,
    "totalPages": 15,
    "currentPage": 1,
    "pageSize": 10,
    "hasMore": true
  }
}

Get a single order

GET /orders/:id
Returns detailed information about a specific order including the product, customer, and review if available.

Customers

List customers

GET /customers
Query parameters:
ParameterTypeDescription
productIdstringFilter by product ID
sortBystringSort field: email, country, numberOfOrders, createdAt
sortOrderstringSort direction: asc or desc
Response:
[
  {
    "_id": "65cust123...",
    "buyerEmail": "customer@example.com",
    "country": "US",
    "numberOfOrders": 3,
    "createdAt": "2024-01-10T09:00:00Z"
  }
]

Get a customer

GET /customers/:id
Returns customer details including order history and reviews.

Reviews

List all reviews

GET /reviews
Returns all reviews for the authenticated user’s products. Response:
[
  {
    "_id": "65rev123...",
    "productId": "65abc123...",
    "buyerEmail": "customer@example.com",
    "rating": 5,
    "review": "Great product!",
    "createdAt": "2024-01-25T16:00:00Z"
  }
]

Get reviews for a product (Public)

GET /reviews/:productId
This endpoint is public and does not require authentication.

Discounts

List discounts

GET /discounts
Returns all discount codes for the authenticated user. Response:
[
  {
    "_id": "65disc123...",
    "name": "Summer Sale",
    "code": "SUMMER20",
    "value": 20,
    "valueType": "percentage",
    "active": true,
    "used": 15
  }
]

Get a discount

GET /discounts/:id

Create a discount

POST /discounts
Request body:
{
  "name": "New Year Sale",
  "code": "NEWYEAR25",
  "value": 25,
  "valueType": "percentage",
  "active": true,
  "mainProductIds": ["65abc123...", "65abc456..."]
}

Update a discount

POST /discounts/:id
Request body:
{
  "name": "Updated Sale",
  "code": "NEWYEAR30",
  "value": 30,
  "valueType": "percentage",
  "active": true,
  "mainProductIds": ["65abc123..."]
}

Delete a discount

DELETE /discounts/:id

Upsells

List upsells

GET /upsells
Returns all upsells and sales data for the authenticated user. Response:
{
  "upsells": [
    {
      "_id": "65ups123...",
      "name": "Premium Upgrade",
      "upsellProductId": "65abc456...",
      "upsellPrice": 29.99,
      "active": true,
      "mainProductIds": ["65abc123..."]
    }
  ],
  "salesWithUpsells": []
}

Get an upsell

GET /upsells/:id

Create an upsell

POST /upsells
Request body:
{
  "name": "Premium Upgrade",
  "mainProductIds": ["65abc123..."],
  "upsellProductId": "65abc456...",
  "upsellPrice": 29.99,
  "upsellDescription": "Get the premium version at a discount!",
  "primaryButtonText": "Yes, upgrade me!",
  "secondaryButtonText": "No thanks",
  "active": true
}

Update an upsell

POST /upsells/:id

Delete an upsell

DELETE /upsells/:id

User Settings

Get current user

GET /users/me
Returns the authenticated user’s profile information.

Update user settings

POST /users/update
Request body:
{
  "firstName": "John",
  "lastName": "Doe",
  "currency": "USD",
  "country": "US"
}

Subscriptions

List subscription customers

POST /orders/subscriptions
Request body:
{
  "page": 1,
  "pageSize": 20,
  "startDate": "2024-01-01",
  "endDate": "2024-12-31"
}

Get subscription details

GET /orders/subscriptions/:id

Cancel a subscription

POST /orders/subscriptions/cancel/:subscriptionId

Refund a subscription

POST /orders/subscriptions/refund/:subscriptionId

Error Handling

All endpoints return standard HTTP status codes:
StatusDescription
200Success
400Bad request (invalid parameters)
401Unauthorized (invalid or missing API key)
404Resource not found
500Internal server error
Error response format:
{
  "message": "Description of the error"
}

Rate Limiting

The API enforces rate limiting of 200 requests per minute per IP address. If you exceed this limit, you’ll receive a 429 Too Many Requests response.

Test Mode vs Live Mode

Your API key determines whether you’re operating in test mode or live mode:
  • Test mode (pk_test_...): Access test data only
  • Live mode (pk_live_...): Access real production data
Test mode is useful for development and testing without affecting real customer data.