# Quick start

Have a destination bucket or table ready. You’ll create a stream, send a test event and check that it arrived.

## 1. Create an ingestion stream

Sign in to the [dashboard](pathname:///app/) and create an ingestion stream, then create an API key on the stream's page. That key writes only to this stream, so requests need no `S2b-Stream` header. Copy it when it is shown: it is displayed once, and afterwards the dashboard shows only its first 14 characters. Keys for several streams are made on the dashboard's API keys page; see [Choosing the stream](./api-reference.md#choosing-the-stream).

```bash
export S2B_API_KEY=s2b_ingest_...
```

## 2. Connect the destination

On the dashboard's Destinations page, create a destination and follow its page under [Destinations](/docs/destinations/), then choose it on the stream's page. Several streams can share one destination. Verify checks access:

- Buckets: it writes a test object under your prefix and reads it back.
- Tables: it creates the table in the namespace you name if it is missing, or checks the existing table's columns, and checks write permissions.

The stream accepts data as soon as it has a destination, verified or not; the first successful delivery verifies it. A stream with no destination gets `409 destination_not_ready`.

## 3. Send a JSON event

Send one object or an array of objects to `/v1/events`:

```bash
curl https://api.send2bucket.com/v1/events \
  -H "Authorization: Bearer $S2B_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[{"event":"order.paid","order_id":"ord_20931","cents":4200},
       {"event":"email.sent","order_id":"ord_20931"}]'
```

The `204 No Content` response, with an empty body, comes after the batch is stored durably. The length of each item's JSON as stored is the number billed.

## 4. Find the records

Batches are delivered at least every 10 seconds on Free and every 60 seconds on Trial, Pro and Team. The records then appear under `<prefix>/s2b/stream=<stream_id>/date=<YYYY-MM-DD>/hour=<HH>/` in your bucket, one gzip NDJSON object per delivery, or as rows in your table. Each record carries the `batch_id` of the request that sent it; see the [delivery format](./delivery-format.md).

## 5. Send OpenTelemetry data

Send2Bucket accepts OTLP over HTTP with protobuf encoding and over gRPC. Both use the same API key.

### OpenTelemetry Collector, OTLP/HTTP

The `otlphttp` exporter appends `/v1/logs`, `/v1/traces` and `/v1/metrics` to the endpoint.

```yaml
exporters:
  otlphttp/s2b:
    endpoint: https://api.send2bucket.com
    headers:
      authorization: Bearer ${env:S2B_API_KEY}
    compression: gzip

service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [otlphttp/s2b]
    traces:
      receivers: [otlp]
      exporters: [otlphttp/s2b]
    metrics:
      receivers: [otlp]
      exporters: [otlphttp/s2b]
```

### OpenTelemetry Collector, OTLP/gRPC

The `otlp` exporter connects over TLS and HTTP/2 to port 443 and sends the key as `authorization` metadata.

```yaml
exporters:
  otlp/s2b:
    endpoint: api.send2bucket.com:443
    headers:
      authorization: Bearer ${env:S2B_API_KEY}
    compression: gzip
```

Reference `otlp/s2b` in the pipelines the same way as above.

### SDK exporters

Most OpenTelemetry SDKs read these variables. The space after `Bearer` is percent-encoded, as the specification requires for header values.

```bash
export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.send2bucket.com
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer%20$S2B_API_KEY"
```

## Next

- [Delivery format](./delivery-format.md) explains the object layout and each NDJSON line.
- [Delivery semantics](./delivery-semantics.md) explains retries, duplicates and ordering.
- [Send events from Cloudflare Workers](./guides/cloudflare-workers-events.md) sends the same request from a Worker without delaying its response.
