> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cloudraker.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cloudraker.com/_mcp/server.

# Fill a form from source documents

POST https://api.cloudraker.com/v1/fill
Content-Type: application/json

Drafts a form PDF's field values from the supplied source documents and returns the completed file.

**Pick the form** with `template`, either shape:

- `{ "id": "…" }` — a saved [template](https://docs.cloudraker.com/api/cloud-raker-api/templates/get-template), or any file you own.
- `{ "url": "…" }` — fetched fresh for this run and purged with it.

**Human review.** `review: "required"` parks the run in `needs_input` with one task per document instead of finishing it. From there you can read the drafted values at [GET /v1/runs/{id}/task](https://docs.cloudraker.com/api/cloud-raker-api/runs/get-run-task), submit corrections to [POST /v1/runs/{id}/task](https://docs.cloudraker.com/api/cloud-raker-api/runs/submit-run-task), or send a person to the ready-made page at `tasks[].url`.

**Shape the output** with `output`: `flattened` (default) bakes the values in, `editable` leaves the form fillable.

```json
{
  "files": [{ "id": "a04d6597-4e34-4a99-94ea-964c289a4c68" }],
  "template": { "id": "23e0a865-0be9-45b1-a491-f1b6bd58a31a" },
  "review": "required"
}
```

### Waiting for the result

Sync by default: the call holds open until the run finishes, up to `?wait=` seconds (default `60`, max `120`, `0` returns immediately).

| Outcome | Response |
| --- | --- |
| Finished inside the window | `200` with the full run |
| Still running at the cap | `202` with `{object, id, status, statusUrl}` |
| Parked for a human | `202` right away, `status: "needs_input"` plus `tasks[]` |

<Note>
The `202` is a graceful degrade, never an error — poll [the run](https://docs.cloudraker.com/api/cloud-raker-api/runs/get-run) or wait for a [webhook](https://docs.cloudraker.com/api/cloud-raker-api/webhooks/create-webhook-endpoint). Replaying an `idempotency-key` returns the original run alongside an `idempotent-replay: true` response header.
</Note>

**Learn more:** [Form filling guide](https://docs.cloudraker.com/capabilities/fill)

Reference: https://docs.cloudraker.com/api/cloud-raker-api/capabilities/fill

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: CloudRaker API
  version: 1.0.0
paths:
  /v1/fill:
    post:
      operationId: fill
      summary: Fill a form from source documents
      description: >-
        Drafts a form PDF's field values from the supplied source documents and
        returns the completed file.


        **Pick the form** with `template`, either shape:


        - `{ "id": "…" }` — a saved
        [template](https://docs.cloudraker.com/api/cloud-raker-api/templates/get-template),
        or any file you own.

        - `{ "url": "…" }` — fetched fresh for this run and purged with it.


        **Human review.** `review: "required"` parks the run in `needs_input`
        with one task per document instead of finishing it. From there you can
        read the drafted values at [GET
        /v1/runs/{id}/task](https://docs.cloudraker.com/api/cloud-raker-api/runs/get-run-task),
        submit corrections to [POST
        /v1/runs/{id}/task](https://docs.cloudraker.com/api/cloud-raker-api/runs/submit-run-task),
        or send a person to the ready-made page at `tasks[].url`.


        **Shape the output** with `output`: `flattened` (default) bakes the
        values in, `editable` leaves the form fillable.


        ```json

        {
          "files": [{ "id": "a04d6597-4e34-4a99-94ea-964c289a4c68" }],
          "template": { "id": "23e0a865-0be9-45b1-a491-f1b6bd58a31a" },
          "review": "required"
        }

        ```


        ### Waiting for the result


        Sync by default: the call holds open until the run finishes, up to
        `?wait=` seconds (default `60`, max `120`, `0` returns immediately).


        | Outcome | Response |

        | --- | --- |

        | Finished inside the window | `200` with the full run |

        | Still running at the cap | `202` with `{object, id, status,
        statusUrl}` |

        | Parked for a human | `202` right away, `status: "needs_input"` plus
        `tasks[]` |


        <Note>

        The `202` is a graceful degrade, never an error — poll [the
        run](https://docs.cloudraker.com/api/cloud-raker-api/runs/get-run) or
        wait for a
        [webhook](https://docs.cloudraker.com/api/cloud-raker-api/webhooks/create-webhook-endpoint).
        Replaying an `idempotency-key` returns the original run alongside an
        `idempotent-replay: true` response header.

        </Note>


        **Learn more:** [Form filling
        guide](https://docs.cloudraker.com/capabilities/fill)
      tags:
        - ''
      parameters:
        - name: wait
          in: query
          description: >-
            How many seconds to hold the request open waiting for the run to
            finish.


            Defaults to `60`, maximum `120`. Finishing inside the window returns
            `200` with the full run; running past it returns `202` with a
            `statusUrl` to poll. Send `0` to skip waiting entirely and always
            get the `202`.
          required: false
          schema:
            type: integer
            default: 60
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The finished run.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1FillRun'
        '400':
          description: Invalid request (`invalid_request` / `invalid_schema`).
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Unusable input file or webhook endpoint.
          content:
            application/json:
              schema:
                description: Any type
        '429':
          description: >-
            Rate limited. The `/v1` API allows at least **67 requests per minute
            per organization** (about 1,000 requests per 15 minutes) — a
            guaranteed floor, enforced per edge location, so a geographically
            spread caller may get more. Wait for the `Retry-After` interval and
            retry — the error is `retryable`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FillRequestTooManyRequestsError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V1FillBody'
servers:
  - url: https://api.cloudraker.com
    description: Production
  - url: https://api.staging.raker.one
    description: Staging
  - url: https://api.dev.raker.one
    description: Development
components:
  schemas:
    V1FillBodyTemplate0:
      type: object
      properties:
        id:
          type: string
      required:
        - id
      title: V1FillBodyTemplate0
    V1FillBodyTemplate1:
      type: object
      properties:
        url:
          type: string
          format: uri
        name:
          type: string
      required:
        - url
      title: V1FillBodyTemplate1
    V1FillBodyTemplate:
      oneOf:
        - $ref: '#/components/schemas/V1FillBodyTemplate0'
        - $ref: '#/components/schemas/V1FillBodyTemplate1'
      description: >-
        The blank form to fill, given one of two ways.


        - `{ "id": "…" }` — a saved template from `POST /v1/templates`, or any
        file you own.

        - `{ "url": "…", "name"?: "…" }` — fetched for this run only and purged
        with it.
      title: V1FillBodyTemplate
    V1FillBodyReview:
      type: string
      enum:
        - none
        - required
      description: >-
        Whether a person checks the drafted values before the form is produced.


        `none` (the default) fills and finishes. `required` parks the run at
        `needs_input` with one task per document — read it at `GET
        /v1/runs/{id}/task`, submit corrections to `POST /v1/runs/{id}/task`, or
        send someone to the ready-made page at `tasks[].url`.
      title: V1FillBodyReview
    V1FillBodyOutput:
      type: string
      enum:
        - flattened
        - editable
      description: >-
        What the produced PDF looks like. `flattened` (the default) bakes the
        values in so nothing can be changed; `editable` leaves the form
        fillable.
      title: V1FillBodyOutput
    V1FillBodyFilesItemsOneOf0Processing:
      type: string
      enum:
        - auto
        - ocr
        - simple
        - transcribe
        - transcribe_diarize
      title: V1FillBodyFilesItemsOneOf0Processing
    V1FillBodyFilesItems0:
      type: object
      properties:
        url:
          type: string
          format: uri
        name:
          type: string
        processing:
          $ref: '#/components/schemas/V1FillBodyFilesItemsOneOf0Processing'
      required:
        - url
      title: V1FillBodyFilesItems0
    V1FillBodyFilesItems1:
      type: object
      properties:
        id:
          type: string
      required:
        - id
      title: V1FillBodyFilesItems1
    V1FillBodyFilesItems:
      oneOf:
        - $ref: '#/components/schemas/V1FillBodyFilesItems0'
        - $ref: '#/components/schemas/V1FillBodyFilesItems1'
      description: >-
        An input file, given one of two ways.


        - `{ "url": "…", "name"?: "…", "processing"?: "…" }` — fetched over
        http(s) for this run and purged with it.

        - `{ "id": "…" }` — a file you already registered with `POST /v1/files`,
        reusable across runs and never re-parsed.
      title: V1FillBodyFilesItems
    V1FillBodyWebhook0:
      type: object
      properties:
        url:
          type: string
          format: uri
      required:
        - url
      title: V1FillBodyWebhook0
    V1FillBodyWebhook1:
      type: object
      properties:
        id:
          type: string
      required:
        - id
      title: V1FillBodyWebhook1
    V1FillBodyWebhook:
      oneOf:
        - $ref: '#/components/schemas/V1FillBodyWebhook0'
        - $ref: '#/components/schemas/V1FillBodyWebhook1'
      description: >-
        Where to deliver this run's events, given one of two ways.


        - `{ "url": "…" }` — a one-off https endpoint for this run only.

        - `{ "id": "whe_…" }` — a saved endpoint from `POST /v1/webhooks`. Runs
        hold the reference, so pausing or re-pointing that endpoint applies to
        this run too.


        Deliveries are at-least-once and signed — dedupe on `eventId` and verify
        against `GET /v1/webhooks/jwks.json`.
      title: V1FillBodyWebhook
    V1FillBody:
      type: object
      properties:
        template:
          $ref: '#/components/schemas/V1FillBodyTemplate'
          description: >-
            The blank form to fill, given one of two ways.


            - `{ "id": "…" }` — a saved template from `POST /v1/templates`, or
            any file you own.

            - `{ "url": "…", "name"?: "…" }` — fetched for this run only and
            purged with it.
        instructions:
          type: string
          description: >-
            Free-form guidance for the drafting pass — which source document
            wins a conflict, how to format dates, which fields to leave blank.
        review:
          $ref: '#/components/schemas/V1FillBodyReview'
          description: >-
            Whether a person checks the drafted values before the form is
            produced.


            `none` (the default) fills and finishes. `required` parks the run at
            `needs_input` with one task per document — read it at `GET
            /v1/runs/{id}/task`, submit corrections to `POST
            /v1/runs/{id}/task`, or send someone to the ready-made page at
            `tasks[].url`.
        output:
          $ref: '#/components/schemas/V1FillBodyOutput'
          description: >-
            What the produced PDF looks like. `flattened` (the default) bakes
            the values in so nothing can be changed; `editable` leaves the form
            fillable.
        action:
          type: string
          description: >-
            A saved fill action to run, by id or slug. Config you send inline is
            merged over the saved config.
        files:
          type: array
          items:
            $ref: '#/components/schemas/V1FillBodyFilesItems'
        metadata:
          type: object
          additionalProperties:
            description: Any type
          description: >-
            Arbitrary JSON you attach to the run and get back on every read of
            it.


            Use it to carry your own identifiers — an order number, a customer
            id — so a webhook or a polled run reconciles without a lookup table.
            Capped at 10 KB serialized.
        webhook:
          $ref: '#/components/schemas/V1FillBodyWebhook'
          description: >-
            Where to deliver this run's events, given one of two ways.


            - `{ "url": "…" }` — a one-off https endpoint for this run only.

            - `{ "id": "whe_…" }` — a saved endpoint from `POST /v1/webhooks`.
            Runs hold the reference, so pausing or re-pointing that endpoint
            applies to this run too.


            Deliveries are at-least-once and signed — dedupe on `eventId` and
            verify against `GET /v1/webhooks/jwks.json`.
        ttl:
          type: integer
          description: >-
            How long, in seconds, to keep this run and its files before purging
            them automatically.


            Defaults to 24 hours; the maximum is 604800 (7 days). The deadline
            comes back as `expiresAt` on every read of the run. Call `POST
            /v1/runs/{id}/keep` before then to clear the TTL and move the
            results into a space permanently.


            E-signature runs are exempt — an envelope waits for its signers
            however long that takes.
      required:
        - template
        - files
      title: V1FillBody
    V1FillRunStatus:
      type: string
      enum:
        - queued
        - processing
        - processed
        - failed
        - cancelled
        - expired
        - needs_input
      description: |-
        Where the run is in its life.

        | Status | Meaning |
        | --- | --- |
        | `queued` | Accepted, not started |
        | `processing` | Work in flight |
        | `needs_input` | Parked for a person — see `tasks[]` |
        | `processed` | Finished; `output` is populated |
        | `failed` | Finished unsuccessfully |
        | `cancelled` | Stopped on request |
        | `expired` | TTL elapsed and the data was purged |

        The last four are terminal.
      title: V1FillRunStatus
    V1FillRunFilesItems:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        status:
          type: string
        error:
          type: string
      required:
        - id
        - name
        - status
      title: V1FillRunFilesItems
    V1FillRunFile:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        status:
          type: string
        error:
          type: string
      required:
        - id
        - name
        - status
      title: V1FillRunFile
    V1FillRunError:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message
      description: >-
        Why the run failed. Present whenever `status` is `failed`, and only
        then.


        `code` is the stable, snake_case reason (`input_unavailable`,
        `parse_failed`, …); `message` is the human-readable detail. Per-file and
        per-step failures are also reported in `files[].error` and, for a
        pipeline, `steps[].error`.
      title: V1FillRunError
    V1FillRunTasksItems:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        url:
          type: string
      required:
        - id
        - title
        - url
      title: V1FillRunTasksItems
    V1FillRunOutputFile:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        url:
          type: string
      required:
        - id
        - name
      title: V1FillRunOutputFile
    V1FillRunOutputFilesItems:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        url:
          type: string
      required:
        - id
        - name
      title: V1FillRunOutputFilesItems
    V1FillRunOutput:
      type: object
      properties:
        file:
          $ref: '#/components/schemas/V1FillRunOutputFile'
        files:
          type: array
          items:
            $ref: '#/components/schemas/V1FillRunOutputFilesItems'
        fields:
          type: object
          additionalProperties:
            description: Any type
      required:
        - files
      description: >-
        The completed form. Present once `status` is `processed`.


        `file` is the filled PDF with a signed download link; `fields` reports
        the values that were written into it, keyed by field name.
      title: V1FillRunOutput
    V1FillRun:
      type: object
      properties:
        object:
          type: string
          enum:
            - fill_run
        id:
          type: string
        status:
          $ref: '#/components/schemas/V1FillRunStatus'
          description: |-
            Where the run is in its life.

            | Status | Meaning |
            | --- | --- |
            | `queued` | Accepted, not started |
            | `processing` | Work in flight |
            | `needs_input` | Parked for a person — see `tasks[]` |
            | `processed` | Finished; `output` is populated |
            | `failed` | Finished unsuccessfully |
            | `cancelled` | Stopped on request |
            | `expired` | TTL elapsed and the data was purged |

            The last four are terminal.
        expiresAt:
          type:
            - string
            - 'null'
        statusUrl:
          type: string
        files:
          type: array
          items:
            $ref: '#/components/schemas/V1FillRunFilesItems'
        file:
          $ref: '#/components/schemas/V1FillRunFile'
        error:
          $ref: '#/components/schemas/V1FillRunError'
          description: >-
            Why the run failed. Present whenever `status` is `failed`, and only
            then.


            `code` is the stable, snake_case reason (`input_unavailable`,
            `parse_failed`, …); `message` is the human-readable detail. Per-file
            and per-step failures are also reported in `files[].error` and, for
            a pipeline, `steps[].error`.
        metadata:
          type: object
          additionalProperties:
            description: Any type
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/V1FillRunTasksItems'
          description: >-
            The human steps currently blocking the run. Present while `status`
            is `needs_input`.


            Each task has a `url` — a ready-made page you can send a person to —
            or you can drive it yourself through `GET` and `POST
            /v1/runs/{id}/task`. E-signature runs never carry `tasks[]`: their
            signing links are signer-held secrets, so use `envelopeUrl` instead.
        output:
          $ref: '#/components/schemas/V1FillRunOutput'
          description: >-
            The completed form. Present once `status` is `processed`.


            `file` is the filled PDF with a signed download link; `fields`
            reports the values that were written into it, keyed by field name.
      required:
        - object
        - id
        - status
        - expiresAt
        - statusUrl
        - files
      title: V1FillRun
    V1FillPostResponsesContentApplicationJsonSchemaCode:
      type: string
      enum:
        - rate_limited
      title: V1FillPostResponsesContentApplicationJsonSchemaCode
    FillRequestTooManyRequestsError:
      type: object
      properties:
        code:
          $ref: >-
            #/components/schemas/V1FillPostResponsesContentApplicationJsonSchemaCode
        message:
          type: string
        retryable:
          type: boolean
        requestId:
          type: string
        docUrl:
          type: string
      required:
        - code
        - message
        - retryable
        - requestId
      title: FillRequestTooManyRequestsError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

```

## Examples

### Example 1



**Request**

```json
{
  "template": {
    "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
  },
  "files": [
    {
      "url": "https://example.com/documents/invoice_12345.pdf"
    }
  ]
}
```

**Response**

```json
{
  "object": "fill_run",
  "id": "9b2f1e4a-3c4d-4f5a-8b7e-1a2c3d4e5f6a",
  "status": "queued",
  "expiresAt": "2024-07-01T12:00:00Z",
  "statusUrl": "https://api.cloudraker.com/v1/runs/9b2f1e4a-3c4d-4f5a-8b7e-1a2c3d4e5f6a/status",
  "files": [
    {
      "id": "a04d6597-4e34-4a99-94ea-964c289a4c68",
      "name": "invoice_12345.pdf",
      "status": "pending",
      "error": ""
    }
  ],
  "file": {
    "id": "b15d7f8e-9c3a-4d2b-8f7e-123456789abc",
    "name": "filled_form.pdf",
    "status": "pending",
    "error": ""
  },
  "error": {
    "code": "",
    "message": ""
  },
  "metadata": {},
  "tasks": [
    {
      "id": "task_001",
      "title": "Review filled form for invoice 12345",
      "url": "https://app.cloudraker.com/tasks/task_001"
    }
  ],
  "output": {
    "files": [
      {
        "id": "a04d6597-4e34-4a99-94ea-964c289a4c68",
        "name": "invoice_12345.pdf",
        "url": "https://cdn.cloudraker.com/uploads/a04d6597-4e34-4a99-94ea-964c289a4c68.pdf"
      }
    ],
    "file": {
      "id": "b15d7f8e-9c3a-4d2b-8f7e-123456789abc",
      "name": "filled_form.pdf",
      "url": "https://cdn.cloudraker.com/filled_forms/b15d7f8e-9c3a-4d2b-8f7e-123456789abc.pdf"
    },
    "fields": {}
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/v1/fill"

payload = {
    "template": { "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479" },
    "files": [{ "url": "https://example.com/documents/invoice_12345.pdf" }]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/v1/fill';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"template":{"id":"f47ac10b-58cc-4372-a567-0e02b2c3d479"},"files":[{"url":"https://example.com/documents/invoice_12345.pdf"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.cloudraker.com/v1/fill"

	payload := strings.NewReader("{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/v1/fill")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.cloudraker.com/v1/fill")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/v1/fill', [
  'body' => '{
  "template": {
    "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
  },
  "files": [
    {
      "url": "https://example.com/documents/invoice_12345.pdf"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/v1/fill");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "template": ["id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"],
  "files": [["url": "https://example.com/documents/invoice_12345.pdf"]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/v1/fill")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Example 2



**Request**

```json
{
  "template": {
    "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
  },
  "files": [
    {
      "url": "https://example.com/documents/invoice_12345.pdf"
    }
  ]
}
```

**Response**

```json
{
  "object": "fill_run",
  "id": "9b2f1e4a-3c4d-4f5a-8b7e-1a2c3d4e5f6a",
  "status": "queued",
  "expiresAt": "2024-07-01T12:00:00Z",
  "statusUrl": "https://api.cloudraker.com/v1/runs/9b2f1e4a-3c4d-4f5a-8b7e-1a2c3d4e5f6a/status",
  "files": [
    {
      "id": "a04d6597-4e34-4a99-94ea-964c289a4c68",
      "name": "invoice_12345.pdf",
      "status": "pending",
      "error": ""
    }
  ],
  "file": {
    "id": "b15d7f8e-9c3a-4d2b-8f7e-123456789abc",
    "name": "filled_form.pdf",
    "status": "pending",
    "error": ""
  },
  "error": {
    "code": "",
    "message": ""
  },
  "metadata": {},
  "tasks": [
    {
      "id": "task_001",
      "title": "Review filled form for invoice 12345",
      "url": "https://app.cloudraker.com/tasks/task_001"
    }
  ],
  "output": {
    "files": [
      {
        "id": "a04d6597-4e34-4a99-94ea-964c289a4c68",
        "name": "invoice_12345.pdf",
        "url": "https://cdn.cloudraker.com/uploads/a04d6597-4e34-4a99-94ea-964c289a4c68.pdf"
      }
    ],
    "file": {
      "id": "b15d7f8e-9c3a-4d2b-8f7e-123456789abc",
      "name": "filled_form.pdf",
      "url": "https://cdn.cloudraker.com/filled_forms/b15d7f8e-9c3a-4d2b-8f7e-123456789abc.pdf"
    },
    "fields": {}
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/v1/fill"

payload = {
    "template": { "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479" },
    "files": [{ "url": "https://example.com/documents/invoice_12345.pdf" }]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/v1/fill';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"template":{"id":"f47ac10b-58cc-4372-a567-0e02b2c3d479"},"files":[{"url":"https://example.com/documents/invoice_12345.pdf"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.cloudraker.com/v1/fill"

	payload := strings.NewReader("{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/v1/fill")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.cloudraker.com/v1/fill")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/v1/fill', [
  'body' => '{
  "template": {
    "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
  },
  "files": [
    {
      "url": "https://example.com/documents/invoice_12345.pdf"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/v1/fill");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"template\": {\n    \"id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n  },\n  \"files\": [\n    {\n      \"url\": \"https://example.com/documents/invoice_12345.pdf\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "template": ["id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"],
  "files": [["url": "https://example.com/documents/invoice_12345.pdf"]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/v1/fill")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```