API Reference
Base URL: https://app.cattleos.com
Authentication
All API requests require a Bearer token in the Authorization header. You can use either a Firebase ID token (for client apps) or a CattleOS API key (for server-to-server integrations).
Authorization: Bearer cos_live_your_key_here
API keys are scoped to a farm and specific resource permissions. Create and manage keys in your dashboard.
Cooper AI
/api/v1/cooper/chatChat with Cooper (AI assistant)Authentication
/api/v1/api-keysCreate an API key/api/v1/api-keysList your API keys/api/v1/api-keys/:idRevoke an API keyCattle
/api/v1/cattleList all cattle/api/v1/cattleCreate a cattle record/api/v1/cattle/:idGet a single animal/api/v1/cattle/:idUpdate a cattle record/api/v1/cattle/:idArchive a cattle recordActivities
/api/v1/activitiesList activities/api/v1/activitiesLog an activity/api/v1/activities/:idGet activity details/api/v1/activities/:idUpdate an activity/api/v1/activities/:idDelete an activityContacts
/api/v1/contactsList contacts/api/v1/contactsCreate a contact/api/v1/contacts/:idGet contact details/api/v1/contacts/:idUpdate a contactFinancial
/api/v1/financial/costsList costs/api/v1/financial/costsRecord a cost/api/v1/financial/revenueList revenue/api/v1/financial/revenueRecord revenue/api/v1/financial/line-itemsList line itemsCooper AI API
Cooper is CattleOS's AI assistant. Send natural language messages and Cooper will query your farm data, create records, and perform actions — all through a simple chat interface. Requires the cooper:chat scope.
Request
POST /api/v1/cooper/chat
Authorization: Bearer cos_live_your_key_here
Content-Type: application/json
{
"messages": [
{"role": "user", "content": "How many cattle do I have?"}
],
"model": "gpt-4o", // optional, default: gpt-4o
"temperature": 0.7, // optional, 0-2
"max_tool_rounds": 5 // optional, 1-10
}Response
{
"data": {
"message": "You have 2,353 cattle across 12 pens.",
"tool_calls": [
{
"name": "list_cattle",
"arguments": {},
"result": { "matchingCount": 2353, "items": [...] }
}
],
"model": "gpt-4o",
"usage": {
"prompt_tokens": 1250,
"completion_tokens": 42,
"total_tokens": 1292
}
}
}Multi-turn Conversations
Pass previous messages to maintain context. Cooper will remember what was discussed and can reference earlier data.
{
"messages": [
{"role": "user", "content": "How many cattle do I have?"},
{"role": "assistant", "content": "You have 2,353 cattle."},
{"role": "user", "content": "How many are in the North Pen?"}
]
}What Cooper Can Do
Cooper has access to 100+ tools covering:
- Cattle — list, create, update, delete, record weights, health treatments
- Pens & Barns — create, manage, move cattle between pens
- Inventory — add feed, medications, track transactions
- Activities & Notes — log daily operations
- Financial — record costs, revenue, cattle sales
- Zones & Properties — manage ranch map, move cattle between zones
- Contacts — manage buyers, vets, suppliers
- Tasks — create and manage farm tasks
Error Responses
All errors follow a consistent format:
{
"error": {
"code": "NOT_FOUND",
"message": "Cattle record not found"
}
}Rate Limits
API keys are limited to 100 requests per minute. Exceeding this limit returns a 429 Too Many Requests response with a Retry-After header.