> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# A2A JSON-RPC endpoint

POST https://api.runtype.com/v1/products/{productId}/surfaces/{surfaceId}/a2a

A2A Protocol v1.0 JSON-RPC 2.0 transport endpoint. The request body is a JSON-RPC 2.0 envelope `{ jsonrpc: "2.0", id?, method, params }` dispatched on `method`. Method names are the 1.0 PascalCase forms; the legacy 0.3 slash-strings are still accepted as tolerant aliases:

* `SendMessage` (alias `message/send`) — params: `{ message, configuration?, metadata? }`; returns an envelope whose `result` is `{ task }`.
* `SendStreamingMessage` (alias `message/stream`) — params: same; returns a `text/event-stream` of A2A 1.0 StreamResponse events.
* `GetTask` (alias `tasks/get`) — params: `{ id | taskId, historyLength? }`; returns a Task envelope.
* `ListTasks` — params: `{ pageSize?, pageToken?, status?, includeArtifacts? }`; returns `{ tasks, nextPageToken, pageSize, totalSize }` (cursor-paginated).
* `CancelTask` (alias `tasks/cancel`) — params: `{ id | taskId }`; returns a Task envelope.
* `SubscribeToTask` (alias `tasks/resubscribe`) — params: `{ id }`; returns a `text/event-stream` of A2A 1.0 StreamResponse events.
  Each streaming `data:` line is a JSON-RPC response carrying a `StreamResponse` oneof (`statusUpdate` / `artifactUpdate`); errors stream as a JSON-RPC error envelope (`google.rpc.Status` form). The body is validated by the handler (not by request-schema middleware) so JSON-RPC error envelopes (`-32700`, METHOD\_NOT\_FOUND, INVALID\_PARAMS) are preserved. Authentication is an A2A surface key (Authorization: Bearer a2a\_xxx or X-API-Key header) or a Clerk JWT (dashboard testing).

Reference: https://docs.runtype.com/api-reference/runtype-api/a-2-a/a-2-a-json-rpc-endpoint

## Authentication

- `Authorization` header (required) — A2A surface key sent as `Authorization: Bearer a2a_...` or `X-API-Key: a2a_...`.

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Path parameters

- `productId` (string, required)
- `surfaceId` (string, required)

## Response

### 200

JSON-RPC response envelope (unary methods) or an SSE event stream (SendStreamingMessage, SubscribeToTask).

- Streaming response of `A2AStreamEvent`.
- A2AStreamEvent0
- A2AStreamEvent1
- A2AStreamEvent2

## Errors

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### A2AStreamEvent0

- `jsonrpc` (enum, required)
  - Allowed values: `2.0`
- `result` (A2AStreamEventOneOf0Result, required)
- `id` (A2AStreamEventOneOf0Id, optional)

### A2AStreamEvent1

- `jsonrpc` (enum, required)
  - Allowed values: `2.0`
- `result` (A2AStreamEventOneOf1Result, required)
- `id` (A2AStreamEventOneOf1Id, optional)

### A2AStreamEvent2

- `error` (A2AJsonRpcError, required)
- `jsonrpc` (enum, required)
  - Allowed values: `2.0`
- `id` (A2AStreamEventOneOf2Id, optional)

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### A2AStreamEventOneOf0Result

- `statusUpdate` (A2AStreamEventOneOf0ResultStatusUpdate, required)

### A2AStreamEventOneOf0Id

- string
- double

### A2AStreamEventOneOf1Result

- `artifactUpdate` (A2AStreamEventOneOf1ResultArtifactUpdate, required)

### A2AStreamEventOneOf1Id

- string
- double

### A2AJsonRpcError

- `code` (double, required)
- `message` (string, required)
- `data` (list of any, optional)

### A2AStreamEventOneOf2Id

- string
- double

### A2AStreamEventOneOf0ResultStatusUpdate

- `contextId` (string, required)
- `status` (A2AStreamEventOneOf0ResultStatusUpdateStatus, required)
- `taskId` (string, required)
- `metadata` (map from string to any, optional)

### A2AStreamEventOneOf1ResultArtifactUpdate

- `artifact` (A2AArtifact, required)
- `contextId` (string, required)
- `taskId` (string, required)
- `append` (boolean, optional)
- `lastChunk` (boolean, optional)
- `metadata` (map from string to any, optional)

### A2AStreamEventOneOf0ResultStatusUpdateStatus

- `state` (enum, required)
  - Allowed values: `TASK_STATE_SUBMITTED`, `TASK_STATE_WORKING`, `TASK_STATE_COMPLETED`, `TASK_STATE_FAILED`, `TASK_STATE_CANCELED`, `TASK_STATE_INPUT_REQUIRED`, `TASK_STATE_AUTH_REQUIRED`, `TASK_STATE_REJECTED`, `TASK_STATE_UNSPECIFIED`
- `message` (A2AMessage, optional)
- `timestamp` (string, optional)

### A2AArtifact

- `artifactId` (string, required)
- `parts` (list of A2APart, required)
- `description` (string, optional)
- `name` (string, optional)

### A2AMessage

- `parts` (list of A2APart, required)
- `role` (enum, required)
  - Allowed values: `ROLE_USER`, `ROLE_AGENT`
- `contextId` (string, optional)
- `messageId` (string, optional)
- `taskId` (string, optional)

### A2APart

- `data` (any, optional)
- `filename` (string, optional)
- `mediaType` (string, optional)
- `raw` (string, optional)
- `text` (string, optional)
- `url` (string, optional)

## Examples

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a"

headers = {"Authorization": "<apiKey>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a';
const options = {method: 'POST', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/products/productId/surfaces/surfaceId/a2a")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```