> 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.

# Fetch external agent card

POST https://api.runtype.com/v1/agents/fetch-agent-card
Content-Type: application/json

Proxy-fetch an external agent card from a URL, avoiding CORS issues. The URL is validated against SSRF attacks. With `transport: "device"`, the card is fetched through the paired local listener `deviceId`, so the URL must be a loopback address on that machine. Pass `bearerToken` when the card itself requires one.

Reference: https://docs.runtype.com/api-reference/runtype-api/agents/fetch-external-agent-card

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

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

## Request

### Body (application/json)

This endpoint expects an object.

- `url` (string, required)
- `bearerToken` (string, optional) — Sent as `Authorization: Bearer` on the card request. Never stored or echoed.
- `deviceId` (string, optional) — The paired listener to fetch through. Required when transport is "device".
- `transport` (enum, optional) — How to reach the card: directly (default) or through a paired local listener
  - Allowed values: `http`, `device`

## Response

### 200

Agent card JSON

- `authentication` (V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaAuthentication, optional)
- `capabilities` (V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaCapabilities, optional)
- `description` (string, optional)
- `iconUrl` (string, optional)
- `name` (string, optional)
- `protocolVersion` (string, optional)
- `provider` (V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaProvider, optional)
- `skills` (list of V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaSkillsItems, optional)
- `url` (string, optional)
- `version` (string, optional)

## Errors

### 400 Bad Request Error

Invalid URL or non-JSON response

- `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.

### 401 Unauthorized Error

Unauthorized

- `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.

### 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.

### 502 Bad Gateway Error

Failed to fetch agent card from remote

- `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

### V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaAuthentication

- `apiKeyAuth` (V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaAuthenticationApiKeyAuth, optional)
- `bearerAuth` (V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaAuthenticationBearerAuth, optional)
- `type` (enum, optional)
  - Allowed values: `bearer`, `api_key`, `none`

### V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaCapabilities

- `pushNotifications` (boolean, optional)
- `statefulness` (enum, optional)
  - Allowed values: `none`, `task`, `session`
- `streaming` (boolean, optional)

### V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaProvider

- `organization` (string, optional)
- `url` (string, optional)

### V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaSkillsItems

- `description` (string, optional)
- `id` (string, optional)
- `inputModes` (list of string, optional)
- `inputSchema` (map from string to any, optional)
- `name` (string, optional)
- `outputModes` (list of string, 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, …).

### V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaAuthenticationApiKeyAuth

- `headerName` (string, optional)

### V1AgentsFetchAgentCardPostResponsesContentApplicationJsonSchemaAuthenticationBearerAuth

- `scopes` (list of string, optional)

## Examples

### Fetch Agent Card

**Request**

```json
{
  "url": "https://example.com/.well-known/agent.json"
}
```

**Response**

```json
{
  "authentication": {
    "apiKeyAuth": {
      "headerName": "string"
    },
    "bearerAuth": {
      "scopes": [
        "string"
      ]
    },
    "type": "bearer"
  },
  "capabilities": {
    "pushNotifications": true,
    "statefulness": "none",
    "streaming": true
  },
  "description": "string",
  "iconUrl": "string",
  "name": "string",
  "protocolVersion": "string",
  "provider": {
    "organization": "string",
    "url": "string"
  },
  "skills": [
    {
      "description": "string",
      "id": "string",
      "inputModes": [
        "string"
      ],
      "inputSchema": {},
      "name": "string",
      "outputModes": [
        "string"
      ]
    }
  ],
  "url": "string",
  "version": "string"
}
```

**SDK Code**

```python Fetch Agent Card
import requests

url = "https://api.runtype.com/v1/agents/fetch-agent-card"

payload = { "url": "https://example.com/.well-known/agent.json" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Fetch Agent Card
const url = 'https://api.runtype.com/v1/agents/fetch-agent-card';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"url":"https://example.com/.well-known/agent.json"}'
};

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

```go Fetch Agent Card
package main

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

func main() {

	url := "https://api.runtype.com/v1/agents/fetch-agent-card"

	payload := strings.NewReader("{\n  \"url\": \"https://example.com/.well-known/agent.json\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

```ruby Fetch Agent Card
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/agents/fetch-agent-card")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"url\": \"https://example.com/.well-known/agent.json\"\n}"

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

```java Fetch Agent Card
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/agents/fetch-agent-card")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"https://example.com/.well-known/agent.json\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/agents/fetch-agent-card', [
  'body' => '{
  "url": "https://example.com/.well-known/agent.json"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Fetch Agent Card
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/agents/fetch-agent-card");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"url\": \"https://example.com/.well-known/agent.json\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Fetch Agent Card
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["url": "https://example.com/.well-known/agent.json"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/agents/fetch-agent-card")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```

### Fetch a local agent card through a listener

**Request**

```json
{
  "url": "http://127.0.0.1:4111/.well-known/agent-card.json",
  "deviceId": "dev_01h455vb4pex5vsknk084sn02q",
  "transport": "device"
}
```

**Response**

```json
{
  "authentication": {
    "apiKeyAuth": {
      "headerName": "string"
    },
    "bearerAuth": {
      "scopes": [
        "string"
      ]
    },
    "type": "bearer"
  },
  "capabilities": {
    "pushNotifications": true,
    "statefulness": "none",
    "streaming": true
  },
  "description": "string",
  "iconUrl": "string",
  "name": "string",
  "protocolVersion": "string",
  "provider": {
    "organization": "string",
    "url": "string"
  },
  "skills": [
    {
      "description": "string",
      "id": "string",
      "inputModes": [
        "string"
      ],
      "inputSchema": {},
      "name": "string",
      "outputModes": [
        "string"
      ]
    }
  ],
  "url": "string",
  "version": "string"
}
```

**SDK Code**

```python Fetch a local agent card through a listener
import requests

url = "https://api.runtype.com/v1/agents/fetch-agent-card"

payload = {
    "url": "http://127.0.0.1:4111/.well-known/agent-card.json",
    "deviceId": "dev_01h455vb4pex5vsknk084sn02q",
    "transport": "device"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Fetch a local agent card through a listener
const url = 'https://api.runtype.com/v1/agents/fetch-agent-card';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"url":"http://127.0.0.1:4111/.well-known/agent-card.json","deviceId":"dev_01h455vb4pex5vsknk084sn02q","transport":"device"}'
};

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

```go Fetch a local agent card through a listener
package main

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

func main() {

	url := "https://api.runtype.com/v1/agents/fetch-agent-card"

	payload := strings.NewReader("{\n  \"url\": \"http://127.0.0.1:4111/.well-known/agent-card.json\",\n  \"deviceId\": \"dev_01h455vb4pex5vsknk084sn02q\",\n  \"transport\": \"device\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

```ruby Fetch a local agent card through a listener
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/agents/fetch-agent-card")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"url\": \"http://127.0.0.1:4111/.well-known/agent-card.json\",\n  \"deviceId\": \"dev_01h455vb4pex5vsknk084sn02q\",\n  \"transport\": \"device\"\n}"

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

```java Fetch a local agent card through a listener
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/agents/fetch-agent-card")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"http://127.0.0.1:4111/.well-known/agent-card.json\",\n  \"deviceId\": \"dev_01h455vb4pex5vsknk084sn02q\",\n  \"transport\": \"device\"\n}")
  .asString();
```

```php Fetch a local agent card through a listener
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/agents/fetch-agent-card', [
  'body' => '{
  "url": "http://127.0.0.1:4111/.well-known/agent-card.json",
  "deviceId": "dev_01h455vb4pex5vsknk084sn02q",
  "transport": "device"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Fetch a local agent card through a listener
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/agents/fetch-agent-card");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"url\": \"http://127.0.0.1:4111/.well-known/agent-card.json\",\n  \"deviceId\": \"dev_01h455vb4pex5vsknk084sn02q\",\n  \"transport\": \"device\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Fetch a local agent card through a listener
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "url": "http://127.0.0.1:4111/.well-known/agent-card.json",
  "deviceId": "dev_01h455vb4pex5vsknk084sn02q",
  "transport": "device"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/agents/fetch-agent-card")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```