Skip to content

Schemas API

Schemas define the expected structure of webhook payloads using JSON Schema. Attach schemas to routes to validate incoming events before delivery.

Endpoints

MethodPathDescription
GET/api/schemasList schemas
POST/api/schemasCreate schema
GET/api/schemas/{id}Get schema
PATCH/api/schemas/{id}Update schema
DELETE/api/schemas/{id}Delete schema

Schema Object

json
{
  "id": "sch_abc123",
  "name": "GitHub Push Event",
  "description": "Validates GitHub push webhook payloads",
  "schema": {
    "type": "object",
    "required": ["ref", "repository", "pusher"],
    "properties": {
      "ref": { "type": "string" },
      "repository": {
        "type": "object",
        "required": ["full_name"],
        "properties": {
          "full_name": { "type": "string" }
        }
      },
      "pusher": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": { "type": "string" }
        }
      }
    }
  },
  "version": 1,
  "routeCount": 2,
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

List Schemas

http
GET /api/schemas

Query Parameters

ParameterTypeDescription
pagenumberPage number (default: 1)
pageSizenumberItems per page (default: 20, max: 100)
searchstringSearch by name

Example

bash
curl https://api.hookbase.app/api/schemas \
  -H "Authorization: Bearer whr_your_api_key"
javascript
const response = await fetch('https://api.hookbase.app/api/schemas', {
  headers: {
    'Authorization': 'Bearer whr_your_api_key'
  }
});
const data = await response.json();
python
import requests

response = requests.get(
  'https://api.hookbase.app/api/schemas',
  headers={'Authorization': 'Bearer whr_your_api_key'}
)
data = response.json()

Response

json
{
  "data": [
    {
      "id": "sch_abc123",
      "name": "GitHub Push Event",
      "version": 1,
      "routeCount": 2,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  ],
  "pagination": {
    "total": 3,
    "page": 1,
    "pageSize": 20
  }
}

Create Schema

http
POST /api/schemas

Request Body

FieldTypeRequiredDescription
namestringYesDisplay name
schemaobjectYesJSON Schema object (draft-07)
descriptionstringNoOptional description

Example

bash
curl -X POST https://api.hookbase.app/api/schemas \
  -H "Authorization: Bearer whr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Stripe Payment Event",
    "description": "Validates Stripe payment_intent webhooks",
    "schema": {
      "type": "object",
      "required": ["type", "data"],
      "properties": {
        "type": {
          "type": "string",
          "pattern": "^payment_intent\\."
        },
        "data": {
          "type": "object",
          "required": ["object"],
          "properties": {
            "object": {
              "type": "object",
              "required": ["id", "amount", "currency"],
              "properties": {
                "id": { "type": "string" },
                "amount": { "type": "integer", "minimum": 0 },
                "currency": { "type": "string", "minLength": 3, "maxLength": 3 }
              }
            }
          }
        }
      }
    }
  }'
javascript
const response = await fetch('https://api.hookbase.app/api/schemas', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer whr_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Stripe Payment Event',
    description: 'Validates Stripe payment_intent webhooks',
    schema: {
      type: 'object',
      required: ['type', 'data'],
      properties: {
        type: {
          type: 'string',
          pattern: '^payment_intent\\.'
        },
        data: {
          type: 'object',
          required: ['object'],
          properties: {
            object: {
              type: 'object',
              required: ['id', 'amount', 'currency'],
              properties: {
                id: { type: 'string' },
                amount: { type: 'integer', minimum: 0 },
                currency: { type: 'string', minLength: 3, maxLength: 3 }
              }
            }
          }
        }
      }
    }
  })
});
const data = await response.json();
python
import requests

response = requests.post(
  'https://api.hookbase.app/api/schemas',
  headers={
    'Authorization': 'Bearer whr_your_api_key',
    'Content-Type': 'application/json'
  },
  json={
    'name': 'Stripe Payment Event',
    'description': 'Validates Stripe payment_intent webhooks',
    'schema': {
      'type': 'object',
      'required': ['type', 'data'],
      'properties': {
        'type': {
          'type': 'string',
          'pattern': '^payment_intent\\.'
        },
        'data': {
          'type': 'object',
          'required': ['object'],
          'properties': {
            'object': {
              'type': 'object',
              'required': ['id', 'amount', 'currency'],
              'properties': {
                'id': { 'type': 'string' },
                'amount': { 'type': 'integer', 'minimum': 0 },
                'currency': { 'type': 'string', 'minLength': 3, 'maxLength': 3 }
              }
            }
          }
        }
      }
    }
  }
)
data = response.json()

Response

json
{
  "id": "sch_new123",
  "name": "Stripe Payment Event",
  "description": "Validates Stripe payment_intent webhooks",
  "schema": { ... },
  "version": 1,
  "routeCount": 0,
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Get Schema

http
GET /api/schemas/{id}

Example

bash
curl https://api.hookbase.app/api/schemas/sch_abc123 \
  -H "Authorization: Bearer whr_your_api_key"
javascript
const response = await fetch('https://api.hookbase.app/api/schemas/sch_abc123', {
  headers: {
    'Authorization': 'Bearer whr_your_api_key'
  }
});
const data = await response.json();
python
import requests

response = requests.get(
  'https://api.hookbase.app/api/schemas/sch_abc123',
  headers={'Authorization': 'Bearer whr_your_api_key'}
)
data = response.json()

Response

Returns the full schema object.

Update Schema

http
PATCH /api/schemas/{id}

Request Body

All fields are optional. Only provided fields are updated.

FieldTypeDescription
namestringDisplay name
schemaobjectJSON Schema object
descriptionstringOptional description

INFO

Updating the schema field automatically increments the version number.

Example

bash
curl -X PATCH https://api.hookbase.app/api/schemas/sch_abc123 \
  -H "Authorization: Bearer whr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "object",
      "required": ["ref", "repository", "pusher", "commits"],
      "properties": {
        "ref": { "type": "string" },
        "commits": { "type": "array", "minItems": 1 }
      }
    }
  }'
javascript
const response = await fetch('https://api.hookbase.app/api/schemas/sch_abc123', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer whr_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    schema: {
      type: 'object',
      required: ['ref', 'repository', 'pusher', 'commits'],
      properties: {
        ref: { type: 'string' },
        commits: { type: 'array', minItems: 1 }
      }
    }
  })
});
const data = await response.json();
python
import requests

response = requests.patch(
  'https://api.hookbase.app/api/schemas/sch_abc123',
  headers={
    'Authorization': 'Bearer whr_your_api_key',
    'Content-Type': 'application/json'
  },
  json={
    'schema': {
      'type': 'object',
      'required': ['ref', 'repository', 'pusher', 'commits'],
      'properties': {
        'ref': { 'type': 'string' },
        'commits': { 'type': 'array', 'minItems': 1 }
      }
    }
  }
)
data = response.json()

Response

Returns the updated schema object with incremented version.

Delete Schema

http
DELETE /api/schemas/{id}

WARNING

A schema cannot be deleted while it is assigned to active routes. Remove it from all routes first.

Example

bash
curl -X DELETE https://api.hookbase.app/api/schemas/sch_abc123 \
  -H "Authorization: Bearer whr_your_api_key"
javascript
const response = await fetch('https://api.hookbase.app/api/schemas/sch_abc123', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer whr_your_api_key'
  }
});
python
import requests

response = requests.delete(
  'https://api.hookbase.app/api/schemas/sch_abc123',
  headers={'Authorization': 'Bearer whr_your_api_key'}
)

Response

204 No Content

Schema Validation Behavior

When a schema is attached to a route:

  1. Incoming event payloads are validated against the JSON Schema
  2. Valid payloads proceed through the route normally
  3. Invalid payloads result in deliveries with status schema_failed
  4. Validation errors are recorded on the delivery for debugging

Viewing Validation Errors

Check the delivery detail for schema validation errors:

json
{
  "id": "dlv_abc123",
  "status": "schema_failed",
  "error": "Schema validation failed: /data/object/amount must be integer, got string",
  "schemaId": "sch_abc123",
  "schemaVersion": 1
}

Error Responses

400 Bad Request

Invalid JSON Schema:

json
{
  "error": "Bad Request",
  "message": "Invalid JSON Schema: 'type' must be a valid JSON Schema type",
  "code": "INVALID_SCHEMA"
}

409 Conflict

Schema in use:

json
{
  "error": "Conflict",
  "message": "Schema is assigned to 2 active routes",
  "code": "RESOURCE_IN_USE"
}

Released under the MIT License.