Troubleshooting
Quick solutions to common integration issues.
Order Creation Issues
"consumer is required"
Problem: You're missing the consumer object entirely.
Solution: Add a consumer object with either an existing ID or new consumer details:
{
"consumer": {
"first_name": "John",
"last_name": "Doe"
}
}
"last_name is required"
Problem: You provided first_name but not last_name.
Solution: When creating a new consumer, both names are required:
{
"consumer": {
"first_name": "John",
"last_name": "Doe" // Required when first_name is provided
}
}
"Either pack_id or contents required"
Problem: Your pouch object is empty or missing product information.
Solution: Each pouch needs either pack_id (for assemblies) OR contents (for custom orders):
- Using Contents
- Using Pack ID
{
"pouches": [
{
"time_of_administration": "Morning",
"contents": [{ "client_product_id": "your-product-uuid" }]
}
]
}
{
"pouches": [
{
"pack_id": "your-assembly-uuid",
"time_of_administration": "Morning"
}
]
}
You cannot use both pack_id and contents in the same pouch.
"client_product_id must be a valid GUID"
Problem: The product ID is not a valid UUID format.
Solution: Product IDs must be valid UUIDs (e.g., d290f1ee-6c54-4b01-90e6-d701748f0851).
- List your products:
GET /v2/products - Copy the exact
idvalue from the response - Use that ID in your order
"The following client products are inactive and cannot be ordered"
Problem: You're trying to order a product that has been deactivated.
Solution:
- Check product status:
GET /v2/products/{id} - Only use products where
active: true - Filter your product list:
GET /v2/products?active=true
"No Packaging Asset Group ID found for the order line"
Problem: Your client doesn't have packaging configured for this order.
Solution: Contact OK Capsule support. Packaging Asset Groups are configured during onboarding. You may need:
- A packaging design approved
- A default PAG assigned to your product line
Authentication Issues
"Token expired"
Problem: Your access token has expired (tokens expire after 24 hours).
Solution: Use your refresh token to get a new access token:
const response = await fetch(
"https://na1-prod.okcapsule.app/v2/authentication/refresh-token",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ refresh_token: yourRefreshToken }),
}
);
const { access_token } = await response.json();
"Unauthorized" (401)
Problem: Missing, invalid, or expired token.
Checklist:
- ✅ Is
Authorizationheader present? - ✅ Does it start with
Bearer(note the space)? - ✅ Is the token from the correct environment (stage vs prod)?
- ✅ Has the token expired?
// Correct format
headers: {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIs..."
}
"Forbidden" (403)
Problem: Your user doesn't have permission for this action.
Solution: Contact your admin to check your user's role and permissions in the client portal.
Environment Issues
Getting 404 errors
Problem: Using wrong base URL or endpoint path.
Solution: Verify you're using the correct environment:
| Environment | Base URL |
|---|---|
| Production | https://na1-prod.okcapsule.app |
| Stage | https://na1-stage.okcapsule.app |
Stage and Production are completely separate. Credentials, products, and data do not transfer between environments.
"Stage credentials don't work in Production"
Problem: Trying to use stage credentials in production (or vice versa).
Solution: Each environment requires separate credentials. Contact OK Capsule to get credentials for both environments if needed.
Order Status Issues
"Order cannot be modified"
Problem: Trying to update an order that's already been accepted.
Solution: Orders can only be modified when status is Pending or On Hold. Once Accepted (after midnight PST processing), orders cannot be changed.
Check order status first:
const response = await fetch(
`https://na1-prod.okcapsule.app/v2/orders/${orderId}`,
{ headers: { Authorization: `Bearer ${token}` } }
);
const { order } = await response.json();
if (order.status === "Pending" || order.status === "On Hold") {
// Can modify
} else {
// Cannot modify - contact support if needed
}
Order stuck in "Needs Changes"
Problem: Validation failed during order processing.
Solution: Check the order's notes for details:
GET /v2/orders/{id}- Check thenotefield- Common causes:
- Inactive packaging design (PAG not approved)
- Products no longer available
- Fix the issue and create a new order
Debugging Checklist
When an API call fails:
- Check HTTP status code - Different codes mean different issues
- Read the full error response - The
detailsarray contains specific field errors - Verify request format - JSON must be valid, Content-Type header must be set
- Check required fields - See Minimal Order Example
- Verify IDs exist - Test with GET requests before using IDs in orders
- Test in Stage first - Use stage environment for development
Getting Help
If you're still stuck:
- Check the Interactive API Docs for endpoint details
- Review Error Handling for error codes
- Contact OK Capsule support with:
- Request URL and method
- Request body (redact sensitive data)
- Full error response
- Timestamp of the request