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

# Create

> Create or update a distributed pipeline

# Destinations

There are currently three flavors of destinations available via self-service APIs: Webhooks, WebSockets, and Postgres.

There are [16 total that are currently supported by Indexing Co](https://indexing-co.notion.site/16e25f031053805da10cf65179f977c6?v=097aa09c71c845db9f88d773385d1f5e) generally though - reach out if you need something else!

## Webhooks

Here's an example payload for creating a pipeline that delivers to a webhook:

```json theme={null}
{
  ...
  "delivery": {
    "adapter": "HTTP",
    "connection": {
      "host": "https://webhook.site/...",
      "headers": {
        "some-auth-key": "some-auth-key"
      }
    }
  },
  ...
}
```

### Signing deliveries (HMAC)

For sensitive payloads you can have each delivery signed so your endpoint can verify it came from us, was not modified in transit, and is not a replay. Add a `signing` block to the webhook `connection`:

```json theme={null}
{
  ...
  "delivery": {
    "adapter": "HTTP",
    "connection": {
      "host": "https://your-app.com/webhooks/indexing",
      "headers": {
        "some-auth-key": "some-auth-key"
      },
      "signing": {
        "secret": "whsec_your_shared_secret",
        "header": "X-Indexing-Signature",
        "tsHeader": "X-Indexing-Timestamp"
      }
    }
  },
  ...
}
```

`header` and `tsHeader` are optional and default to `X-Indexing-Signature` and `X-Indexing-Timestamp`. Each delivery then carries:

| Header                 | Value                                                                     |
| ---------------------- | ------------------------------------------------------------------------- |
| `X-Indexing-Timestamp` | Unix time in seconds when the request was signed                          |
| `X-Indexing-Signature` | `sha256=<hex>`, where `<hex> = HMAC_SHA256(secret, "<timestamp>.<body>")` |

To verify, recompute the HMAC over `"<timestamp>.<rawBody>"` and compare it to `X-Indexing-Signature` in constant time:

```js theme={null}
const crypto = require('crypto');

function verify(req, secret) {
  const ts = req.header('X-Indexing-Timestamp');
  const sig = req.header('X-Indexing-Signature'); // "sha256=<hex>"
  if (!ts || !sig) return false;
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; // reject replays

  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(`${ts}.${req.rawBody}`).digest('hex');
  const a = Buffer.from(sig);
  const b = Buffer.from(expected);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}
```

<Note>
  Verify against the **raw request body bytes**, not a re-serialized JSON object — whitespace or key-ordering differences will break the comparison. In Express, capture the raw body with `express.json({ verify: (req, _res, buf) => { req.rawBody = buf.toString('utf8'); } })`.
</Note>

## WebSockets

Here's an example payload for creating a pipeline that delivers to a websocket:

```json theme={null}
{
  ...
  "delivery": {
    "adapter": "WEBSOCKET",
    "connection": {
      "host": "ws://websocket-host.com/...",
      "headers": {
        "some-auth-key": "some-auth-key"
      }
    }
  },
  ...
}
```

## Postgres

Here's an example payload for creating a pipeline that delivers to a Postgres database:

```json theme={null}
{
  ...
  "delivery": {
    "adapter": "POSTGRES",
    "connectionUri": "postgres://...",
    "table": "vitalik_token_transfers",
    "uniqueKeys": ["transaction_hash", "log_index"]
  },
  ...
}
```

<Note>
  Make sure your database table is already setup! Importantly, this also includes ensuring that there's a unique / primary key index on the table matching the provided `uniqueKeys` in the pipeline.
</Note>


## OpenAPI

````yaml POST /pipelines
openapi: 3.1.0
info:
  title: The Neighborhood - OpenAPI
  description: Schema for testing, deploying, and managing distributed pipelines
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://app.indexing.co/dw
security:
  - ApiKeyAuth: []
paths:
  /pipelines:
    post:
      description: Create or modify a pipeline
      requestBody:
        description: Pipeline to save
        content:
          application/json:
            schema:
              required:
                - name
                - transformation
                - filter
                - filterKeys
                - networks
                - delivery
              type: object
              properties:
                name:
                  type: string
                transformation:
                  type: string
                filter:
                  type: string
                filterKeys:
                  type: array
                  items:
                    type: string
                networks:
                  type: array
                  items:
                    type: string
                enabled:
                  type: boolean
                delivery:
                  type: object
                  properties:
                    adapter:
                      type: string
                    connection:
                      type: string
                    connectionUri:
                      type: string
                    table:
                      type: string
                    uniqueKeys:
                      type: array
                      items:
                        type: string
        required: true
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                required:
                  - message
                type: object
                properties:
                  message:
                    type: string
        '400':
          description: unexpected error
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    type: string
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````