# Create Register

Returns a registered frame and instance token, or refuses at the status of the reason.

> Page: https://langwatch.ai/docs/api-reference/agents/create-register
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/agents/create-register.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`POST https://app.langwatch.ai/api/v1/agents/connect/register`

## Authentication

### project_api_key

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Request body (required)

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "protocol": {"type":"number","const":1},
    "type": {"type":"string","const":"register"},
    "sdk": {
      "type": "object",
      "properties": {
        "name": {"type":"string","minLength":1,"maxLength":64},
        "version": {"type":"string","minLength":1,"maxLength":64},
        "language": {"type":"string","minLength":1,"maxLength":32}
      },
      "required": ["name","version","language"]
    },
    "instance": {
      "type": "object",
      "properties": {
        "id": {"type":"string","minLength":1,"maxLength":128},
        "hostname": {"type":"string","maxLength":255},
        "username": {"type":"string","maxLength":255},
        "pid": {"type":"integer","minimum":0,"maximum":9007199254740991},
        "startedAt": {"type":"string","maxLength":64},
        "label": {"type":"string","maxLength":128},
        "inFlightCallIds": {
          "default": [],
          "maxItems": 1000,
          "type": "array",
          "items": {"type":"string","maxLength":128}
        },
        "maxConcurrency": {"type":"integer","exclusiveMinimum":0,"maximum":1000}
      },
      "required": ["id","hostname","username","pid","startedAt"]
    },
    "agents": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {"type":"string","minLength":1,"maxLength":255},
          "environment": {"type":"string","minLength":1,"maxLength":64},
          "parameters": {
            "default": {},
            "type": "object",
            "propertyNames": {"type":"string"},
            "additionalProperties": {}
          },
          "concurrency": {"type":"integer","exclusiveMinimum":0,"maximum":1000},
          "timeoutMs": {"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},
          "sticky": {"type":"boolean"},
          "hooks": {
            "type": "object",
            "properties": {"setup":{"type":"boolean"},"teardown":{"type":"boolean"}},
            "required": ["setup","teardown"]
          }
        },
        "required": ["name","environment"]
      }
    }
  },
  "required": ["protocol","type","sdk","instance","agents"]
}
```

## Request example

```bash
curl --request POST \
  --url 'https://app.langwatch.ai/api/v1/agents/connect/register' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"protocol":1,"type":"register","sdk":{"name":"string","version":"string","language":"string"},"instance":{"id":"string","hostname":"string","username":"string","pid":0,"startedAt":"string","label":"string","inFlightCallIds":[],"maxConcurrency":0},"agents":[{"name":"string","environment":"string","parameters":{},"concurrency":0,"timeoutMs":0,"sticky":false,"hooks":{"setup":false,"teardown":false}}]}'
```

## Responses

### 200

Success

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "frame": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "protocol": {"type":"number","const":1},
            "type": {"type":"string","const":"registered"},
            "agents": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {"type":"string"},
                  "environment": {"type":"string"},
                  "id": {"type":"string"},
                  "url": {"type":"string"},
                  "parameterNotes": {"type":"array","items":{"type":"string"}},
                  "scope": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {"kind":{"type":"string","const":"shared"}},
                        "required": ["kind"],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {"kind":{"type":"string","const":"owner"}},
                        "required": ["kind"],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {"type":"string","const":"host"},
                          "hostLabel": {"type":"string"}
                        },
                        "required": ["kind","hostLabel"],
                        "additionalProperties": false
                      }
                    ]
                  }
                },
                "required": ["name","environment","id","url","parameterNotes","scope"],
                "additionalProperties": false
              }
            },
            "heartbeatIntervalMs": {"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},
            "instanceId": {"type":"string"}
          },
          "required": ["protocol","type","agents","heartbeatIntervalMs","instanceId"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "protocol": {"type":"number","const":1},
            "type": {"type":"string","const":"refused"},
            "code": {
              "type": "string",
              "enum": [
                "api_key_invalid",
                "project_required",
                "permission_denied",
                "key_type_not_allowed",
                "replica_count_unsupported",
                "parameters_invalid",
                "environment_invalid",
                "protocol_invalid"
              ]
            },
            "message": {"type":"string"},
            "meta": {
              "type": "object",
              "propertyNames": {"type":"string"},
              "additionalProperties": {}
            }
          },
          "required": ["protocol","type","code","message"],
          "additionalProperties": false
        }
      ]
    },
    "instanceToken": {"type":"string"}
  },
  "required": ["frame"],
  "additionalProperties": false
}
```

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
