Blocks API

Manage reusable content blocks that can be shared across multiple prompts

GET
/tenants/{tenantId}/blocks
Auth Required

List Blocks

Retrieve a paginated list of all blocks for a tenant

Path Parameters

NameTypeDescription
tenantId
Required
stringUnique identifier for the tenant workspace

Query Parameters

NameTypeDescription
page
numberPage number for pagination
Default: 1
per_page
numberNumber of results per page (max: 100)
Default: 20
search
stringSearch by name or description

Examples

curl -X GET \
  'https://api.staging.agnt.ai/tenants/tenant_123/blocks?page=1&per_page=20' \
  -H 'Authorization: Bearer sk_live_your_service_key_here' \
  -H 'Content-Type: application/json'

Response Example

200 OK
{
  "data": [
    {
      "blockName": "data_validator",
      "description": "Validates and sanitizes user input",
      "usedByPrompts": ["customer_support_agent", "email_responder"],
      "createdAt": "2024-01-10T08:00:00Z",
      "updatedAt": "2024-01-15T10:30:00Z"
    }
  ],
  "page": 1,
  "per_page": 20,
  "has_more": false
}
GET
/tenants/{tenantId}/blocks/{blockName}
Auth Required

Get Block

Retrieve detailed information about a specific block

Path Parameters

NameTypeDescription
tenantId
Required
stringUnique identifier for the tenant workspace
blockName
Required
stringUnique name identifier for the block

Examples

curl -X GET \
  'https://api.staging.agnt.ai/tenants/tenant_123/blocks/data_validator' \
  -H 'Authorization: Bearer sk_live_your_service_key_here' \
  -H 'Content-Type: application/json'

Response Example

200 OK
{
  "data": {
    "blockName": "data_validator",
    "content": "function validateData(input) { return input.trim(); }",
    "description": "Validates and sanitizes user input",
    "usedByPrompts": ["customer_support_agent", "email_responder"],
    "createdAt": "2024-01-10T08:00:00Z",
    "updatedAt": "2024-01-15T10:30:00Z"
  }
}
POST
/tenants/{tenantId}/blocks
Auth Required

Create Block

Create a new reusable block

Path Parameters

NameTypeDescription
tenantId
Required
stringUnique identifier for the tenant workspace

Request Body

NameTypeDescription
blockName
Required
stringUnique name identifier for the block (lowercase, underscores)
content
Required
stringThe block content (code, template, etc.)
description
Required
stringDescription of the block purpose

Examples

curl -X POST \
  'https://api.staging.agnt.ai/tenants/tenant_123/blocks' \
  -H 'Authorization: Bearer sk_live_your_service_key_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "blockName": "data_validator",
    "content": "function validateData(input) { return input.trim(); }",
    "description": "Validates and sanitizes user input"
  }'

Response Example

200 OK
{
  "data": {
    "blockName": "data_validator",
    "description": "Validates and sanitizes user input",
    "usedByPrompts": [],
    "createdAt": "2024-01-16T10:00:00Z"
  }
}
PATCH
/tenants/{tenantId}/blocks/{blockName}
Auth Required

Update Block

Update an existing block

Path Parameters

NameTypeDescription
tenantId
Required
stringUnique identifier for the tenant workspace
blockName
Required
stringUnique name identifier for the block

Request Body

NameTypeDescription
content
stringThe block content (code, template, etc.)
description
stringDescription of the block purpose

Examples

curl -X PATCH \
  'https://api.staging.agnt.ai/tenants/tenant_123/blocks/data_validator' \
  -H 'Authorization: Bearer sk_live_your_service_key_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "content": "function validateData(input) { /* updated */ return input.trim(); }",
    "description": "Updated description"
  }'

Response Example

200 OK
{
  "data": {
    "blockName": "data_validator",
    "content": "function validateData(input) { /* updated */ return input.trim(); }",
    "description": "Updated description",
    "usedByPrompts": ["customer_support_agent", "email_responder"],
    "updatedAt": "2024-01-16T11:00:00Z"
  }
}
DELETE
/tenants/{tenantId}/blocks/{blockName}
Auth Required

Delete Block

Delete a block

Path Parameters

NameTypeDescription
tenantId
Required
stringUnique identifier for the tenant workspace
blockName
Required
stringUnique name identifier for the block

Examples

curl -X DELETE \
  'https://api.staging.agnt.ai/tenants/tenant_123/blocks/data_validator' \
  -H 'Authorization: Bearer sk_live_your_service_key_here'

Response Example

200 OK
{
  "message": "Block deleted successfully"
}