> **Photon Beta documentation**
> Browse all pages: https://photon.codes/docs/beta/llms.txt
> Search Beta docs via MCP: https://photon.codes/docs/beta/mcp (OAuth REST API MCP: https://mcp.photon.codes/mcp)

# Event reference

> The generated Socket.IO event and acknowledgement contract.

The AsyncAPI document defines incoming commands, outgoing events, and acknowledgement shapes. Its messages describe Socket.IO argument tuples; use a Socket.IO client to encode the transport packets.

[Download the AsyncAPI contract](https://api.photon.codes/asyncapi.yaml)

Download the generated event contract.

The schema is generated from runtime definitions and checked for drift. Behavioral tests separately check sequencing, replay, limits, and cleanup. See [Start a session](/docs/beta/api-reference/websocket/session.md) and [Cursors and replay](/docs/beta/api-reference/websocket/cursors.md) for those obligations.

## AsyncAPI

```json
{
  "asyncapi": "3.0.0",
  "channels": {
    "Root": {
      "address": "/",
      "bindings": {
        "ws": {
          "bindingVersion": "0.1.0",
          "headers": {
            "properties": {
              "connection": {
                "const": "Upgrade",
                "type": "string"
              },
              "upgrade": {
                "const": "websocket",
                "type": "string"
              }
            },
            "type": "object"
          },
          "method": "GET",
          "query": {
            "externalDocs": {
              "description": "Engine.IO Protocol",
              "url": "https://socket.io/docs/v4/engine-io-protocol/"
            },
            "properties": {
              "EIO": {
                "const": "4",
                "description": "The version of the protocol",
                "type": "string"
              },
              "sid": {
                "description": "The session identifier",
                "type": "string"
              },
              "transport": {
                "description": "The name of the transport",
                "enum": [
                  "websocket"
                ],
                "type": "string"
              }
            },
            "required": [
              "EIO",
              "transport"
            ],
            "type": "object"
          }
        }
      },
      "messages": {
        "rootAckForIncomingReply": {
          "payload": {
            "items": {
              "not": {}
            },
            "maxItems": 1,
            "minItems": 1,
            "prefixItems": [
              {
                "discriminator": {
                  "propertyName": "ok"
                },
                "oneOf": [
                  {
                    "additionalProperties": false,
                    "description": "Accepted for forwarding; does not acknowledge downstream processing.",
                    "properties": {
                      "eventId": {
                        "type": "string"
                      },
                      "ok": {
                        "const": true,
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "ok",
                      "eventId"
                    ],
                    "type": "object"
                  },
                  {
                    "additionalProperties": false,
                    "properties": {
                      "error": {
                        "additionalProperties": false,
                        "properties": {
                          "code": {
                            "enum": [
                              "protocol_violation",
                              "subscribe_timeout",
                              "frame_too_large",
                              "slow_consumer",
                              "capacity",
                              "server_draining",
                              "upstream_unavailable",
                              "internal",
                              "reply_unknown_event",
                              "reply_invalid",
                              "reply_too_large",
                              "reply_publish_failed",
                              "reply_capacity",
                              "reply_forbidden",
                              "subscribe_repeated",
                              "frame_invalid"
                            ],
                            "type": "string"
                          },
                          "eventId": {
                            "type": "string"
                          },
                          "fatal": {
                            "type": "boolean"
                          },
                          "message": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "retryAfterMs": {
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991,
                            "type": "integer"
                          },
                          "retryable": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "code",
                          "message",
                          "fatal",
                          "retryable"
                        ],
                        "type": "object"
                      },
                      "ok": {
                        "const": false,
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "ok",
                      "error"
                    ],
                    "type": "object"
                  }
                ]
              }
            ],
            "type": "array"
          },
          "title": "Acknowledgement for reply"
        },
        "rootAckForIncomingSubscribe": {
          "payload": {
            "items": {
              "not": {}
            },
            "maxItems": 1,
            "minItems": 1,
            "prefixItems": [
              {
                "discriminator": {
                  "propertyName": "ok"
                },
                "oneOf": [
                  {
                    "additionalProperties": false,
                    "properties": {
                      "apiVersion": {
                        "type": "string"
                      },
                      "connectionId": {
                        "type": "string"
                      },
                      "limits": {
                        "additionalProperties": false,
                        "properties": {
                          "maxFrameBytes": {
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991,
                            "type": "integer"
                          },
                          "maxReplyBodyBytes": {
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991,
                            "type": "integer"
                          }
                        },
                        "required": [
                          "maxFrameBytes",
                          "maxReplyBodyBytes"
                        ],
                        "type": "object"
                      },
                      "ok": {
                        "const": true,
                        "type": "boolean"
                      },
                      "projectId": {
                        "type": "string"
                      },
                      "startSeq": {
                        "maximum": 9007199254740991,
                        "minimum": 0,
                        "type": "integer"
                      },
                      "traceId": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "ok",
                      "projectId",
                      "apiVersion",
                      "connectionId",
                      "startSeq",
                      "limits"
                    ],
                    "type": "object"
                  },
                  {
                    "additionalProperties": false,
                    "properties": {
                      "error": {
                        "additionalProperties": false,
                        "properties": {
                          "code": {
                            "enum": [
                              "protocol_violation",
                              "subscribe_timeout",
                              "frame_too_large",
                              "slow_consumer",
                              "capacity",
                              "server_draining",
                              "upstream_unavailable",
                              "internal",
                              "reply_unknown_event",
                              "reply_invalid",
                              "reply_too_large",
                              "reply_publish_failed",
                              "reply_capacity",
                              "reply_forbidden",
                              "subscribe_repeated",
                              "frame_invalid"
                            ],
                            "type": "string"
                          },
                          "eventId": {
                            "type": "string"
                          },
                          "fatal": {
                            "type": "boolean"
                          },
                          "message": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "retryAfterMs": {
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991,
                            "type": "integer"
                          },
                          "retryable": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "code",
                          "message",
                          "fatal",
                          "retryable"
                        ],
                        "type": "object"
                      },
                      "ok": {
                        "const": false,
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "ok",
                      "error"
                    ],
                    "type": "object"
                  }
                ]
              }
            ],
            "type": "array"
          },
          "title": "Acknowledgement for subscribe"
        },
        "rootIncomingReply": {
          "name": "reply",
          "payload": {
            "items": {
              "not": {}
            },
            "maxItems": 1,
            "minItems": 1,
            "prefixItems": [
              {
                "additionalProperties": false,
                "properties": {
                  "body": {
                    "description": "Standard base64 response body, padded or unpadded.",
                    "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$",
                    "type": "string"
                  },
                  "errorReason": {
                    "type": "string"
                  },
                  "eventId": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "headers": {
                    "additionalProperties": {
                      "type": "string"
                    },
                    "propertyNames": {
                      "type": "string"
                    },
                    "type": "object"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "const": 0,
                        "type": "number"
                      },
                      {
                        "maximum": 599,
                        "minimum": 100,
                        "type": "integer"
                      }
                    ]
                  }
                },
                "required": [
                  "eventId"
                ],
                "type": "object"
              }
            ],
            "type": "array"
          },
          "title": "reply"
        },
        "rootIncomingSubscribe": {
          "name": "subscribe",
          "payload": {
            "items": {
              "not": {}
            },
            "maxItems": 1,
            "minItems": 1,
            "prefixItems": [
              {
                "additionalProperties": false,
                "properties": {
                  "apiVersion": {
                    "description": "Customer event contract date to pin for this subscription. Omit to use the server default. The date must be selectable by the server; unsupported dates are rejected. Send it again when resubscribing after reconnect.",
                    "format": "date",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                    "type": "string"
                  },
                  "startSeq": {
                    "description": "0 starts live; a positive cursor resumes after that sequence.",
                    "maximum": 9007199254740991,
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "startSeq"
                ],
                "type": "object"
              }
            ],
            "type": "array"
          },
          "title": "subscribe"
        },
        "rootOutgoingDelivery": {
          "name": "delivery",
          "payload": {
            "items": {
              "not": {}
            },
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
              {
                "allOf": [
                  {
                    "additionalProperties": {},
                    "properties": {
                      "id": {
                        "minLength": 1,
                        "type": "string"
                      },
                      "type": {
                        "minLength": 1,
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "type"
                    ],
                    "type": "object"
                  },
                  {
                    "additionalProperties": {},
                    "propertyNames": {
                      "type": "string"
                    },
                    "type": "object"
                  }
                ]
              },
              {
                "additionalProperties": false,
                "properties": {
                  "replyExpected": {
                    "type": "boolean"
                  },
                  "seq": {
                    "maximum": 9007199254740991,
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "seq",
                  "replyExpected"
                ],
                "type": "object"
              }
            ],
            "type": "array"
          },
          "title": "delivery"
        },
        "rootOutgoingDeliveryError": {
          "name": "delivery_error",
          "payload": {
            "items": {
              "not": {}
            },
            "maxItems": 1,
            "minItems": 1,
            "prefixItems": [
              {
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "enum": [
                      "protocol_violation",
                      "subscribe_timeout",
                      "frame_too_large",
                      "slow_consumer",
                      "capacity",
                      "server_draining",
                      "upstream_unavailable",
                      "internal",
                      "reply_unknown_event",
                      "reply_invalid",
                      "reply_too_large",
                      "reply_publish_failed",
                      "reply_capacity",
                      "reply_forbidden",
                      "subscribe_repeated",
                      "frame_invalid"
                    ],
                    "type": "string"
                  },
                  "eventId": {
                    "type": "string"
                  },
                  "fatal": {
                    "type": "boolean"
                  },
                  "message": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "retryAfterMs": {
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991,
                    "type": "integer"
                  },
                  "retryable": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "code",
                  "message",
                  "fatal",
                  "retryable"
                ],
                "type": "object"
              }
            ],
            "type": "array"
          },
          "title": "delivery_error"
        }
      },
      "servers": [
        {
          "$ref": "#/servers/event-delivery"
        }
      ],
      "title": "Event Delivery"
    }
  },
  "components": {
    "securitySchemes": {
      "projectApiKey": {
        "description": "Enter your complete project API key (`pho_sk_...`) without the `Bearer ` prefix. It is sent as `Authorization: Bearer <project API key>`. The key must belong to the `projectId` in the connection URL.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "defaultContentType": "text/plain",
  "info": {
    "title": "Photon AsyncAPI",
    "version": "1.0.0"
  },
  "operations": {
    "RootRecvOperationReply": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/Root"
      },
      "description": "The message consumed by the application within the / namespace",
      "messages": [
        {
          "$ref": "#/channels/Root/messages/rootIncomingReply"
        }
      ],
      "reply": {
        "address": {
          "description": "Last argument: acknowledgement handler",
          "location": "$message.payload#"
        },
        "channel": {
          "$ref": "#/channels/Root"
        },
        "messages": [
          {
            "$ref": "#/channels/Root/messages/rootAckForIncomingReply"
          }
        ]
      },
      "summary": "Incoming event reply",
      "title": "reply"
    },
    "RootRecvOperationSubscribe": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/Root"
      },
      "description": "The message consumed by the application within the / namespace",
      "messages": [
        {
          "$ref": "#/channels/Root/messages/rootIncomingSubscribe"
        }
      ],
      "reply": {
        "address": {
          "description": "Last argument: acknowledgement handler",
          "location": "$message.payload#"
        },
        "channel": {
          "$ref": "#/channels/Root"
        },
        "messages": [
          {
            "$ref": "#/channels/Root/messages/rootAckForIncomingSubscribe"
          }
        ]
      },
      "summary": "Incoming event subscribe",
      "title": "subscribe"
    },
    "RootSendOperationDelivery": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/Root"
      },
      "description": "The message produced by the application within the / namespace",
      "messages": [
        {
          "$ref": "#/channels/Root/messages/rootOutgoingDelivery"
        }
      ],
      "summary": "Outgoing event delivery",
      "title": "delivery"
    },
    "RootSendOperationDeliveryError": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/Root"
      },
      "description": "The message produced by the application within the / namespace",
      "messages": [
        {
          "$ref": "#/channels/Root/messages/rootOutgoingDeliveryError"
        }
      ],
      "summary": "Outgoing event delivery_error",
      "title": "delivery_error"
    }
  },
  "servers": {
    "event-delivery": {
      "host": "api.photon.codes",
      "pathname": "/v1/projects/{projectId}/events/ws",
      "protocol": "wss",
      "security": [
        {
          "$ref": "#/components/securitySchemes/projectApiKey"
        }
      ],
      "variables": {
        "projectId": {
          "default": "YOUR_PROJECT_ID",
          "description": "The project to subscribe to."
        }
      }
    }
  }
}
```
