Skip to content

API Reference

REST API endpoints for TAVP CMS.

Authentication

All API endpoints require a Bearer token:

bash
curl -H "Authorization: Bearer YOUR_TOKEN" https://yoursite.com/api/cms/types

Generate tokens with:

bash
tavp hub:make:resource ApiToken
# Or manually in config/cms.php

Content Types

MethodEndpointDescription
GET/api/cms/typesList all content types

Records

MethodEndpointDescription
GET/api/cms/{type}Browse records (paginated)
GET/api/cms/{type}/{id}Read a single record
POST/api/cms/{type}Create a record
PUT/api/cms/{type}/{id}Update a record
DELETE/api/cms/{type}/{id}Delete a record

Query Parameters (Browse)

ParamDefaultDescription
page1Page number
per_page15Items per page (max: 100)
statusFilter by status
MethodEndpointDescription
GET/api/cms/search?q={query}Full-text search
GET/api/cms/search?q={query}&type=postSearch within type

Taxonomy

MethodEndpointDescription
GET/api/cms/taxonomy/{type}List terms (category, tag)
POST/api/cms/taxonomyCreate a term

Revisions

MethodEndpointDescription
GET/api/cms/{type}/{id}/revisionsRevision history
POST/api/cms/{type}/{id}/rollback/{ts}Rollback to revision

Sitemap

MethodEndpointDescription
GET/sitemap.xmlAuto-generated sitemap

Response Format

json
{
    "data": {},
    "meta": {
        "total": 100,
        "per_page": 15,
        "current_page": 1
    }
}

Error Response

json
{
    "error": "Not found",
    "message": "Record not found"
}

Examples

Browse Posts

bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "https://yoursite.com/api/cms/post?page=1&per_page=10"

Create Post

bash
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"Hello","slug":"hello","body":"World","status":"published"}' \
  https://yoursite.com/api/cms/post

Search

bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "https://yoursite.com/api/cms/search?q=hello&type=post"

Released under the MIT License.