> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP API

> Call the Formal API directly over HTTP with the Connect protocol

## Overview

Call the Formal API directly over HTTP. It uses the
[Connect protocol](https://connectrpc.com/docs/protocol/), not REST. Every
method is a `POST` to `https://api.formal.ai/<package>.<Service>/<Method>` with a
JSON body.

## Authentication

```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
export FORMAL_API_KEY="<YOUR_API_KEY>"
```

## Example Requests

> [tab] List Resources
>
> ```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> curl -X POST "https://api.formal.ai/core.v1.ResourceService/ListResources" \
>   -H "X-API-KEY: $FORMAL_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{"limit": 50}'
> ```

> [tab] Create User
>
> ```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> curl -X POST "https://api.formal.ai/core.v1.UserService/CreateUser" \
>   -H "X-API-KEY: $FORMAL_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "type": "human",
>     "human": {
>       "first_name": "Alice",
>       "last_name": "Smith",
>       "email": "alice@example.com"
>     }
>   }'
> ```

> [tab] Query Logs
>
> ```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> # Logs for alice@example.com over the last 24 hours (Unix seconds)
> curl -X POST "https://api.formal.ai/core.v1.LogsService/ListLogsV2" \
>   -H "X-API-KEY: $FORMAL_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d "{
>     \"query\": \"user.formal.user.email:alice@example.com\",
>     \"start_timestamp\": \"$(( $(date +%s) - 86400 ))\",
>     \"end_timestamp\": \"$(date +%s)\",
>     \"limit\": 50
>   }"
> ```

> [!NOTE]
>
> The API requires HTTP/2. `curl` negotiates it automatically over HTTPS.
> HTTP/1.1-only clients receive a `464` error.

## API Documentation

See the [API Reference](https://docs.formal.ai/docs/api/introduction.md) for complete endpoint documentation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.