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

# Create a Loop

> Your webhook URL must be `https` and publicly reachable (loopback and
private addresses are rejected). On success you get back the Loop
along with a **signing secret** — shown once, at creation, and never
retrievable again. If you lose it, delete the Loop and create a new
one.




## OpenAPI

````yaml /openapi.json post /v1/loops
openapi: 3.1.0
info:
  title: EnrichLoop API
  version: 0.1.0
  description: |
    Send us a company. We enrich it and send the result back — either to you
    directly, or to a webhook you register (a **Loop**). Built for teams
    enriching data as part of a pipeline: signups, CRM records, lead lists,
    anything that needs a company's firmographic data attached to it.

    ## How it works

    1. You send us something to enrich — a domain or a LinkedIn company URL.
    2. We check whether we already know it. If we do, the task settles
       immediately.
    3. If we don't, we go find it — resolving the domain, locating the
       company's LinkedIn page, and pulling structured data from it — and
       queue the result for you.
    4. You get the result by polling the task, or by registering a Loop and
       having it delivered to your webhook automatically.

    Every enqueue endpoint (`POST /v1/companies/enrich`, `POST
    /v1/loops/{id}/run`) always responds with a task id only — never the
    company data inline, even when the task settles instantly off the cache.
    `200` vs. `202` tells you whether it already settled; either way, fetch
    the result from `GET /v1/tasks/{id}` or via your Loop's webhook.
  contact:
    name: EnrichLoop support
servers:
  - url: https://api.enrichloop.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Companies
    description: Enqueue a company enrichment.
  - name: Tasks
    description: Poll or list the async tasks behind an enrichment.
  - name: Loops
    description: Webhook delivery — register a destination and send records to it.
paths:
  /v1/loops:
    post:
      tags:
        - Loops
      summary: Create a Loop
      description: |
        Your webhook URL must be `https` and publicly reachable (loopback and
        private addresses are rejected). On success you get back the Loop
        along with a **signing secret** — shown once, at creation, and never
        retrievable again. If you lose it, delete the Loop and create a new
        one.
      operationId: createLoop
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                slug:
                  type: string
                  description: |
                    URL-safe identifier, unique per organization. Derived
                    from `name` if omitted. Lowercase letters, numbers and
                    single hyphens, 2–64 characters.
                object_type:
                  type: string
                  enum:
                    - company
                  default: company
                operation:
                  type: string
                  enum:
                    - enrich
                  default: enrich
                webhook_url:
                  type: string
                  format: uri
              required:
                - name
                - webhook_url
              additionalProperties: false
      responses:
        '201':
          description: The created Loop, including its signing secret.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/LoopWithSecret'
                required:
                  - data
        '400':
          description: Malformed body, or a webhook URL that fails the safety check.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: A Loop with this slug already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    LoopWithSecret:
      allOf:
        - $ref: '#/components/schemas/Loop'
      description: The one response where `destination.secret` is populated.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    Loop:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        slug:
          type: string
        object_type:
          type: string
          enum:
            - company
        operation:
          type: string
          enum:
            - enrich
        enabled:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        destination:
          $ref: '#/components/schemas/LoopDestination'
      required:
        - id
        - name
        - slug
        - object_type
        - operation
        - enabled
        - created_at
        - updated_at
    LoopDestination:
      type: object
      properties:
        kind:
          type: string
          enum:
            - webhook
        url:
          type: string
          format: uri
        enabled:
          type: boolean
        secret:
          type: string
          description: >-
            Only present in the response to `POST /v1/loops` — never returned
            afterwards.
      required:
        - kind
        - url
        - enabled
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        text/plain:
          schema:
            type: string
            example: Unauthorized
    TooManyRequests:
      description: |
        Rate limited. `Retry-After` gives the number of seconds to wait. A
        `code: "queue_full"` body means the organization's queued-task
        backlog is full rather than the per-IP request rate being exceeded.
      headers:
        Retry-After:
          schema:
            type: integer
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              code:
                type: string
                enum:
                  - queue_full
              queuedTasks:
                type: integer
            required:
              - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        Pass your API key as a bearer token: `Authorization: Bearer
        YOUR_API_KEY`. Generate and manage keys from your dashboard under
        **Settings → API Keys**.

````