Skip to main content

Overview

The REST API Gateway provides HTTP/HTTPS access to Solace Agent Mesh agents with support for:
  • Synchronous and asynchronous task execution
  • Server-Sent Events (SSE) for real-time streaming
  • File upload and download
  • Session management
  • Agent discovery

Base URL

http://localhost:8080/api/v1
All endpoints are prefixed with /api/v1.

Authentication

Development Mode

When enforce_authentication: false:
curl http://localhost:8080/api/v1/agent-cards
No authentication required.

Production Mode

When enforce_authentication: true, include bearer token:
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://localhost:8080/api/v1/agent-cards

Core Endpoints

Execute Task

Execute a task on an agent asynchronously.
POST /tasks
endpoint
Create and execute a new task.
Request Body:
{
  "agentName": "FileSystemAgent",
  "sessionId": "user123_session",
  "message": {
    "text": "List all files in the current directory"
  },
  "metadata": {
    "priority": "high",
    "tags": ["filesystem", "query"]
  }
}
agentName
string
required
Name of the agent to execute the task.
sessionId
string
required
Session identifier for conversation history.
message
object
required
Message to send to the agent.Subfields:
  • text (string): Text message content
  • files (array): Attached file artifacts
metadata
object
Optional metadata for the task.
Response:
taskId
string
Unique identifier for the created task.
status
string
Initial task status (“queued” or “running”).
sseUrl
string
URL to connect for streaming updates.
{
  "taskId": "task_abc123",
  "status": "running",
  "sseUrl": "/api/v1/tasks/task_abc123/stream"
}

Stream Task Updates

Connect to Server-Sent Events stream for real-time task updates.
GET /tasks/{taskId}/stream
endpoint
Stream task execution updates via SSE.
SSE Event Types:
task.status
event
Task status updates (queued, running, completed, failed).
{
  "taskId": "task_abc123",
  "status": "running",
  "timestamp": "2024-01-15T10:30:00Z"
}
task.message
event
Agent response messages.
{
  "taskId": "task_abc123",
  "message": {
    "text": "I found 5 files in the directory:",
    "role": "agent"
  }
}
artifact.created
event
Artifact creation notifications.
{
  "taskId": "task_abc123",
  "artifact": {
    "filename": "file_list.txt",
    "version": 1,
    "mimeType": "text/plain",
    "size": 1024
  }
}
artifact.progress
event
Artifact upload/download progress.
{
  "taskId": "task_abc123",
  "filename": "large_file.zip",
  "status": "in-progress",
  "bytesTransferred": 512000,
  "totalBytes": 1048576
}
Example (JavaScript):
const eventSource = new EventSource(
  `http://localhost:8080/api/v1/tasks/task_abc123/stream`
);

eventSource.addEventListener('task.message', (event) => {
  const data = JSON.parse(event.data);
  console.log('Agent response:', data.message.text);
});

eventSource.addEventListener('task.status', (event) => {
  const data = JSON.parse(event.data);
  if (data.status === 'completed') {
    console.log('Task completed!');
    eventSource.close();
  }
});

Get Task Status

Retrieve current task status and results.
GET /tasks/{taskId}
endpoint
Get task information and final results.
Response:
taskId
string
Task identifier.
status
string
Current status: “queued”, “running”, “completed”, “failed”, “cancelled”.
result
object
Task results (when status is “completed”).
error
object
Error details (when status is “failed”).
{
  "taskId": "task_abc123",
  "status": "completed",
  "result": {
    "message": {
      "text": "Task completed successfully."
    },
    "artifacts": [
      {
        "filename": "result.json",
        "version": 1
      }
    ]
  },
  "startedAt": "2024-01-15T10:30:00Z",
  "completedAt": "2024-01-15T10:30:15Z"
}

Cancel Task

Cancel a running or queued task.
DELETE /tasks/{taskId}
endpoint
Cancel task execution.
Response:
{
  "taskId": "task_abc123",
  "status": "cancelled",
  "message": "Task cancelled successfully"
}

Session Management

List Sessions

GET /sessions
endpoint
List all sessions for the authenticated user.
Query Parameters:
limit
integer
Maximum number of sessions to return (default: 50).
offset
integer
Pagination offset (default: 0).
Response:
{
  "sessions": [
    {
      "sessionId": "user123_session",
      "agentName": "FileSystemAgent",
      "createdAt": "2024-01-15T10:00:00Z",
      "lastActivityAt": "2024-01-15T10:30:00Z",
      "messageCount": 5
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0
}

Get Session History

GET /sessions/{sessionId}
endpoint
Get conversation history for a session.
Response:
{
  "sessionId": "user123_session",
  "agentName": "FileSystemAgent",
  "messages": [
    {
      "role": "user",
      "text": "List all files",
      "timestamp": "2024-01-15T10:30:00Z"
    },
    {
      "role": "agent",
      "text": "I found 5 files...",
      "timestamp": "2024-01-15T10:30:05Z"
    }
  ]
}

Delete Session

DELETE /sessions/{sessionId}
endpoint
Delete a session and its history.
Response:
{
  "message": "Session deleted successfully"
}

Agent Discovery

List Available Agents

GET /agent-cards
endpoint
Discover available agents in the mesh.
Response:
agents
array
List of available agents with capabilities.
{
  "agents": [
    {
      "agentName": "FileSystemAgent",
      "displayName": "File System",
      "description": "Interacts with the local filesystem",
      "capabilities": {
        "inputModes": ["text"],
        "outputModes": ["text", "file"],
        "supportsStreaming": true
      },
      "skills": [
        {
          "name": "read_files",
          "description": "Read file contents"
        },
        {
          "name": "write_files",
          "description": "Create or update files"
        }
      ]
    }
  ]
}

Artifact Management

Upload Artifact

POST /artifacts
endpoint
Upload a file as an artifact.
Request (multipart/form-data):
curl -X POST \
  -F "[email protected]" \
  -F "description=Important document" \
  -F "sessionId=user123_session" \
  http://localhost:8080/api/v1/artifacts
Response:
{
  "filename": "document.pdf",
  "version": 1,
  "mimeType": "application/pdf",
  "size": 524288,
  "description": "Important document",
  "uploadedAt": "2024-01-15T10:30:00Z"
}

Download Artifact

GET /artifacts/{filename}
endpoint
Download an artifact file.
Query Parameters:
version
integer
Specific version to download (default: latest).
sessionId
string
Session identifier (required if artifact scope is “session”).
Response: Binary file download with appropriate Content-Type header.

List Artifacts

GET /artifacts
endpoint
List available artifacts.
Query Parameters:
sessionId
string
Filter by session.
pattern
string
Glob pattern to filter filenames.
Response:
{
  "artifacts": [
    {
      "filename": "document.pdf",
      "versions": [1],
      "latestVersion": 1,
      "mimeType": "application/pdf",
      "size": 524288,
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ]
}

Error Responses

All errors follow this format:
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Agent 'UnknownAgent' not found",
    "details": {
      "agentName": "UnknownAgent"
    }
  }
}

Error Codes

INVALID_REQUEST
error
Malformed request or invalid parameters.
AUTHENTICATION_REQUIRED
error
Missing or invalid authentication token.
AGENT_NOT_FOUND
error
Specified agent does not exist.
SESSION_NOT_FOUND
error
Specified session does not exist.
TASK_NOT_FOUND
error
Specified task does not exist.
ARTIFACT_NOT_FOUND
error
Specified artifact does not exist.
INTERNAL_ERROR
error
Server-side error.

Rate Limiting

Default rate limits:
  • 100 requests per minute per IP
  • 1000 requests per hour per user
Rate limit headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1642248000

Complete Example

Execute Task with Streaming

// 1. Create task
const createResponse = await fetch('http://localhost:8080/api/v1/tasks', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    agentName: 'FileSystemAgent',
    sessionId: 'user123_session',
    message: {
      text: 'List all files and create a summary report',
    },
  }),
});

const { taskId, sseUrl } = await createResponse.json();

// 2. Connect to SSE stream
const eventSource = new EventSource(
  `http://localhost:8080${sseUrl}`
);

// 3. Handle streaming updates
eventSource.addEventListener('task.message', (event) => {
  const data = JSON.parse(event.data);
  console.log('Agent:', data.message.text);
});

eventSource.addEventListener('artifact.created', (event) => {
  const data = JSON.parse(event.data);
  console.log('Artifact created:', data.artifact.filename);
});

eventSource.addEventListener('task.status', (event) => {
  const data = JSON.parse(event.data);
  if (data.status === 'completed') {
    console.log('Task completed!');
    eventSource.close();
    
    // 4. Download artifact
    window.location.href = 
      `http://localhost:8080/api/v1/artifacts/summary_report.md`;
  }
});

See Also

Build docs developers (and LLMs) love