Ranch.Bot
Skip to reference

Files API

HTTP reference for files. Read authentication and access before using these operations. All examples use made-up data and placeholder credentials.

GET /v1/file

Get Files

Current files HTTP operation. External credential scopes: read:records. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Pagination accepts integer skip and take; set both explicitly. An omitted value passes through to the data query. Collection property names differ by resource; use the response schema. Production rate limit: 100 requests per 15-minute window, per legacy key, otherwise per client IP. RateLimit headers report the current window; respect Retry-After on 429.

ParameterInRequiredSchema
skipqueryNo{"type":"integer"}
takequeryNo{"type":"integer"}
animal_idqueryNo{"type":"string","format":"uuid"}
group_idqueryNo{"type":"string","format":"uuid"}
record_idqueryNo{"type":"string","format":"uuid"}
record_item_idqueryNo{"type":"string","format":"uuid"}
user_idqueryNo{"type":"string","format":"uuid"}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/file' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
429Rate limit exceeded. Retry after the indicated delay.application/json
500Unexpected server failure.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
totalnumberRequired
filesarrayRequired
files[]objectRequired
files[].idstringRequired
files[].created_atstringRequiredformat: "date-time"
files[].updated_atstringRequiredformat: "date-time"
files[].namestringRequired
files[].is_activebooleanRequired
files[].mime_typestringRequired
files[].sizenumberRequired
files[].urlstringRequired
json example
{
  "total": 1,
  "files": []
}

DELETE /v1/file/{file_id}

Delete File

Current files HTTP operation. External credential scopes: write:records. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Direct requests execute without an app confirmation screen. Production rate limit: 100 requests per 15-minute window, per legacy key, otherwise per client IP. RateLimit headers report the current window; respect Retry-After on 429. Deletion behavior is described below; a successful status does not imply erasure from all retained history. Deletes the accessible file through the file service. Marks the file inactive; do not interpret this as immediate storage erasure.

ParameterInRequiredSchema
file_idpathYes{"type":"string","format":"uuid"}

Request example

bash example
curl --fail-with-body -X DELETE \
  'https://api.ranch.bot/v1/file/<file_id>' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
204Completed; no response body.No body
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
429Rate limit exceeded. Retry after the indicated delay.application/json
500Unexpected server failure.application/json

GET /v1/file/{file_id}

Get File

Current files HTTP operation. External credential scopes: read:records. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Production rate limit: 100 requests per 15-minute window, per legacy key, otherwise per client IP. RateLimit headers report the current window; respect Retry-After on 429.

ParameterInRequiredSchema
file_idpathYes{"type":"string","format":"uuid"}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/file/<file_id>' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
429Rate limit exceeded. Retry after the indicated delay.application/json
500Unexpected server failure.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
fileobjectRequired
file.idstringRequired
file.created_atstringRequiredformat: "date-time"
file.updated_atstringRequiredformat: "date-time"
file.namestringRequired
file.is_activebooleanRequired
file.mime_typestringRequired
file.sizenumberRequired
file.urlstringRequired
signedUrlstringRequired
json example
{
  "file": {
    "id": "11111111-1111-4111-8111-111111111111",
    "created_at": "2026-09-01T12:00:00.000Z",
    "updated_at": "2026-09-01T12:00:00.000Z",
    "name": "Example",
    "is_active": true,
    "mime_type": "example",
    "size": 1,
    "url": "example"
  },
  "signedUrl": "example"
}

Unlink File

Current files HTTP operation. External credential scopes: write:records. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Direct requests execute without an app confirmation screen. Production rate limit: 100 requests per 15-minute window, per legacy key, otherwise per client IP. RateLimit headers report the current window; respect Retry-After on 429. Deletion behavior is described below; a successful status does not imply erasure from all retained history. Removes the supplied associations; this is not file deletion.

ParameterInRequiredSchema
file_idpathYes{"type":"string","format":"uuid"}

Request body (application/json)

FieldTypePresenceConstraints
animal_idsarrayOptional
animal_ids[]stringRequiredformat: "uuid"
group_idsarrayOptional
group_ids[]stringRequiredformat: "uuid"
record_idsarrayOptional
record_ids[]stringRequiredformat: "uuid"
record_item_idsarrayOptional
record_item_ids[]stringRequiredformat: "uuid"
user_idsarrayOptional
user_ids[]stringRequiredformat: "uuid"
json example
{}

Request example

bash example
curl --fail-with-body -X DELETE \
  'https://api.ranch.bot/v1/file/<file_id>/link' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{}'

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
429Rate limit exceeded. Retry after the indicated delay.application/json
500Unexpected server failure.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
fileobjectRequired
file.idstringRequired
file.created_atstringRequiredformat: "date-time"
file.updated_atstringRequiredformat: "date-time"
file.namestringRequired
file.is_activebooleanRequired
file.mime_typestringRequired
file.sizenumberRequired
file.urlstringRequired
json example
{
  "file": {
    "id": "11111111-1111-4111-8111-111111111111",
    "created_at": "2026-09-01T12:00:00.000Z",
    "updated_at": "2026-09-01T12:00:00.000Z",
    "name": "Example",
    "is_active": true,
    "mime_type": "example",
    "size": 1,
    "url": "example"
  }
}

POST /v1/file/{file_id}/link

Link File

Current files HTTP operation. External credential scopes: write:records. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Direct requests execute without an app confirmation screen. Production rate limit: 100 requests per 15-minute window, per legacy key, otherwise per client IP. RateLimit headers report the current window; respect Retry-After on 429.

ParameterInRequiredSchema
file_idpathYes{"type":"string","format":"uuid"}

Request body (application/json)

FieldTypePresenceConstraints
animal_idsarrayOptional
animal_ids[]stringRequiredformat: "uuid"
group_idsarrayOptional
group_ids[]stringRequiredformat: "uuid"
record_idsarrayOptional
record_ids[]stringRequiredformat: "uuid"
record_item_idsarrayOptional
record_item_ids[]stringRequiredformat: "uuid"
user_idsarrayOptional
user_ids[]stringRequiredformat: "uuid"
json example
{}

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/file/<file_id>/link' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{}'

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
429Rate limit exceeded. Retry after the indicated delay.application/json
500Unexpected server failure.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
fileobjectRequired
file.idstringRequired
file.created_atstringRequiredformat: "date-time"
file.updated_atstringRequiredformat: "date-time"
file.namestringRequired
file.is_activebooleanRequired
file.mime_typestringRequired
file.sizenumberRequired
file.urlstringRequired
json example
{
  "file": {
    "id": "11111111-1111-4111-8111-111111111111",
    "created_at": "2026-09-01T12:00:00.000Z",
    "updated_at": "2026-09-01T12:00:00.000Z",
    "name": "Example",
    "is_active": true,
    "mime_type": "example",
    "size": 1,
    "url": "example"
  }
}

POST /v1/file/upload

Upload File

Current files HTTP operation. External credential scopes: write:records. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Direct requests execute without an app confirmation screen. Production rate limit: 100 requests per 15-minute window, per legacy key, otherwise per client IP. RateLimit headers report the current window; respect Retry-After on 429. Accepted types: JPEG, PNG, GIF, WebP images (10 MB each); MP4, QuickTime and AVI video (100 MB each); JSON, PDF and CSV documents (5 MB each). Maximum 10 files per request.

ParameterInRequiredSchema
entity_typequeryNo{"type":"string","enum":["animal","group","record","user"]}
entity_idqueryNo{"type":"string","format":"uuid"}

Request body (multipart/form-data)

FieldTypePresenceConstraints
filesarrayRequiredminItems: 1; maxItems: 10
files[]stringRequiredformat: "binary"

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/file/upload' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -F 'files=@/path/to/example.pdf'

Responses

StatusMeaningContent type
201Successapplication/json
400Errorapplication/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
429Rate limit exceeded. Retry after the indicated delay.application/json
500Unexpected server failure.application/json

201 response schema (application/json)

FieldTypePresenceConstraints
successbooleanRequired
errorsarrayRequired
errors[]objectRequired
dataobjectRequired
data.filesarrayRequired
data.files[]objectRequired
data.files[].idstringRequired
data.files[].created_atstringRequiredformat: "date-time"
data.files[].updated_atstringRequiredformat: "date-time"
data.files[].namestringRequired
data.files[].is_activebooleanRequired
data.files[].mime_typestringRequired
data.files[].sizenumberRequired
data.files[].urlstringRequired
json example
{
  "success": true,
  "errors": [],
  "data": {
    "files": []
  }
}

400 response schema (application/json)

FieldTypePresenceConstraints
(variant 1)objectRequired
(variant 1).successbooleanRequired
(variant 1).errorsarrayRequired
(variant 1).errors[]objectRequired
(variant 1).errors[].messagestringRequired
(variant 1).datanullRequired
(variant 2)objectRequired
(variant 2).successbooleanRequiredconst: false
(variant 2).errorsarrayRequired
(variant 2).errors[]objectRequired
(variant 2).errors[].codeintegerOptional
(variant 2).errors[].namestringOptional
(variant 2).errors[].messagestringRequired
(variant 2).datanullOptional
json example
{
  "success": false,
  "errors": [
    {
      "message": "No files provided"
    }
  ],
  "data": null
}

Error body

Validation and authentication errors generally use this envelope. Rate-limit errors omit data; OAuth polling also has protocol-specific errors shown in its reference.

json example
{
  "success": false,
  "errors": [
    {
      "code": 400,
      "name": "ValidationError",
      "message": "Example validation failure"
    }
  ]
}