# Event JSON Schema

JSON Schema (draft 2020-12) for the envelope and each data type.

> Source: https://tokenearly.com/en/developers/rest/schema · Docs index: https://tokenearly.com/en/developers/llms.txt · OpenAPI: https://api.tokenearly.com/v1/openapi.json

`GET https://api.tokenearly.com/v1/schema`

No key required and not rate limited. Use it to validate incoming events or generate types.

**Public, no key needed**

## Parameters

No parameters.

## Example request

**cURL**

```bash
curl "https://api.tokenearly.com/v1/schema"
```

**Python**

```python
import requests

resp = requests.get("https://api.tokenearly.com/v1/schema", timeout=10)
resp.raise_for_status()
print(resp.json())
```

**Node.js**

```javascript
// Node 18+ (built-in fetch)
async function main() {
  const resp = await fetch("https://api.tokenearly.com/v1/schema");
  console.log(await resp.json());
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
```

**Go**

```go
package main

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

func main() {
	req, _ := http.NewRequest("GET", "https://api.tokenearly.com/v1/schema", nil)
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.Status, string(body))
}
```

## Example response

```json
{
  "spec_version": "1.0",
  "event": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://api.tokenearly.com/v1/schema/event",
    "title": "Tokenearly event",
    "allOf": [
      "…"
    ],
    "$defs": {
      "announcement": "…",
      "news": "…",
      "signal": "…",
      "twitter": "…"
    }
  },
  "envelope": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Tokenearly event envelope",
    "type": "object",
    "required": [
      "spec_version",
      "id",
      "revision",
      "action",
      "topic",
      "type",
      "source",
      "published_at",
      "detected_at_ms",
      "data"
    ],
    "properties": {
      "id": {
        "type": "string",
        "description": "Stable event id (24 hex characters) shared by every revision; never changes. Ids increase with the time the event was first stored and compare correctly as strings. Also the pagination and resume cursor."
      },
      "…": "…"
    }
  },
  "data": {
    "announcement": {
      "title": "announcement data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    },
    "news": {
      "title": "news data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    },
    "signal": {
      "title": "signal data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    },
    "twitter": {
      "title": "twitter data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    }
  }
}
```
