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

# Job lifecycle

> Poll status, read results and cancel a crawl by its id.

export const OutcrawlStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('outcrawl-overrides')) {
    const s = document.createElement('style');
    s.id = 'outcrawl-overrides';
    s.textContent = `
      /* Match the product's radius grid (4 / 6 / 8 / 9999), not Mintlify's default. */
      .rounded-sm { border-radius: 0.375rem !important; } /* 6px, --r-ctl */
      .rounded-md { border-radius: 0.375rem !important; } /* 6px, --r-ctl */
      .rounded-lg { border-radius: 0.5rem !important; }   /* 8px, --r-panel */
      .rounded-l-sm { border-top-left-radius: 0.375rem !important; border-bottom-left-radius: 0.375rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.375rem !important; border-bottom-right-radius: 0.375rem !important; }
      .rounded-l-md { border-top-left-radius: 0.375rem !important; border-bottom-left-radius: 0.375rem !important; }
      .rounded-r-md { border-top-right-radius: 0.375rem !important; border-bottom-right-radius: 0.375rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }

      /* Cards: never pure white in light mode, matching the one-big-card surface tone. */
      .card { background-color: #fcfcfc !important; border-radius: 0.5rem !important; }
      html.dark .card { background-color: #141311 !important; }

      /* Docs hero box */
      .oc-hero { background-color: #fcfcfc; border: 1px solid #e5e2dc; }
      html.dark .oc-hero { background-color: #141311; border-color: #26241f; }
      html.dark .oc-hero h1 { color: #edeae4; }

      /* Thin, transparent-track, hide-until-hover scrollbar. */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<OutcrawlStyles />

A crawl's id, from the first frame of its stream, is what every call on this page needs: `crawl.id` in TypeScript, `crawl.job["id"]` in Python once the first frame has arrived. Store it before you need it, especially if the connection that started the crawl might drop.

```mermaid theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
flowchart LR
    A[submit] --> B[status]
    B --> C[results]
    B --> D[cancel]
    C --> B
```

## Status

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  import { Outcrawl } from '@outcrawl/sdk';

  const oc = new Outcrawl();
  const job = await oc.crawl.get('<id>');
  console.log(job.status, job.discovered, job.completed, job.credits, job.failures);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  import asyncio
  from outcrawl import Outcrawl

  async def main():
      async with Outcrawl() as oc:
          job = await oc.crawl.get("<id>")
          print(job["status"], job["discovered"], job["completed"], job["credits"], job["failures"])

  asyncio.run(main())
  ```

  ```bash curl theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  curl https://api.outcrawl.ai/v1/crawl/<id> \
    -H "Authorization: Bearer ock_YOUR_KEY_ID.YOUR_SECRET"
  ```
</CodeGroup>

Status, pages discovered, pages completed, spend so far, and the per-URL failures. Safe to poll, it is a row read and not a browser.

## Results

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  import { Outcrawl } from '@outcrawl/sdk';

  const oc = new Outcrawl();
  let cursor: string | undefined;
  do {
    const batch = await oc.crawl.results('<id>', { cursor });
    for (const record of batch) {
      console.log(record.page.url, record.page.markdown);
    }
    cursor = batch.cursor;
  } while (cursor !== undefined);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  import asyncio
  from outcrawl import Outcrawl

  async def main():
      async with Outcrawl() as oc:
          cursor = None
          while True:
              batch = await oc.crawl.results("<id>", cursor=cursor)
              for record in batch:
                  print(record["page"]["url"], record["page"].get("markdown"))
              cursor = batch.cursor
              if cursor is None:
                  break

  asyncio.run(main())
  ```

  ```bash curl theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  curl "https://api.outcrawl.ai/v1/crawl/<id>/results?cursor=<cursor>" \
    -H "Authorization: Bearer ock_YOUR_KEY_ID.YOUR_SECRET"
  ```
</CodeGroup>

The pages a crawl has delivered, oldest first, paginated with a `cursor`. Pages land during the crawl, so this answers before the crawl has finished, and a cancelled crawl still delivers what it had already fetched.

## Cancel

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  import { Outcrawl } from '@outcrawl/sdk';

  const oc = new Outcrawl();
  const job = await oc.crawl.cancel('<id>');
  console.log(job.status, job.completed);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  import asyncio
  from outcrawl import Outcrawl

  async def main():
      async with Outcrawl() as oc:
          job = await oc.crawl.cancel("<id>")
          print(job["status"], job["completed"])

  asyncio.run(main())
  ```

  ```bash curl theme={"theme":{"light":"github-light","dark":"catppuccin-mocha"}}
  curl -X POST https://api.outcrawl.ai/v1/crawl/<id>/cancel \
    -H "Authorization: Bearer ock_YOUR_KEY_ID.YOUR_SECRET"
  ```
</CodeGroup>

Stops a crawl. It settles with the pages already reached. Pages already fetched stay billed, the `limit` you set on submit is the spending protection, not a refund argued afterward.

<Note>
  If the connection that started a streaming crawl drops, the crawl itself is cancelled. These three calls are how you read the pages you already paid for afterward.
</Note>


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