# at.functions.run

> Published by [hamburgerz.bsky.social](https://lexicon.garden/identity/did:plc:vsnj4aaxyatiht4spdht2q2t)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:vsnj4aaxyatiht4spdht2q2t/at.functions.run)
- [Documentation](https://lexicon.garden/lexicon/did:plc:vsnj4aaxyatiht4spdht2q2t/at.functions.run/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:vsnj4aaxyatiht4spdht2q2t/at.functions.run/examples)

## Definitions

### `at.functions.run`

**Type**: `procedure`

Invoke a registered AT Function

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `input` | `unknown` | Yes | JSON input passed to the function |
| `function` | `string` | Yes | at:// URI of the at.functions.metadata record |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `ok` | `boolean` | Yes | Whether execution succeeded |
| `error` | `string` | No | Error message if execution failed |
| `output` | `unknown` | No | JSON output from the function |
| `durationMs` | `integer` | No | Wall-clock execution time in milliseconds |
| `functionCid` | `string` | No | CID of the function record |

## Raw Schema

```json
{
  "id": "at.functions.run",
  "defs": {
    "main": {
      "type": "procedure",
      "input": {
        "schema": {
          "type": "object",
          "required": [
            "function",
            "input"
          ],
          "properties": {
            "input": {
              "type": "unknown",
              "description": "JSON input passed to the function"
            },
            "function": {
              "type": "string",
              "description": "at:// URI of the at.functions.metadata record"
            }
          }
        },
        "encoding": "application/json"
      },
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "ok"
          ],
          "properties": {
            "ok": {
              "type": "boolean",
              "description": "Whether execution succeeded"
            },
            "error": {
              "type": "string",
              "description": "Error message if execution failed"
            },
            "output": {
              "type": "unknown",
              "description": "JSON output from the function"
            },
            "durationMs": {
              "type": "integer",
              "description": "Wall-clock execution time in milliseconds"
            },
            "functionCid": {
              "type": "string",
              "description": "CID of the function record"
            }
          }
        },
        "encoding": "application/json"
      },
      "description": "Invoke a registered AT Function"
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
