> For the complete documentation index, see [llms.txt](https://docs.tagshelf.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tagshelf.dev/sdks.md). Agents can also search and read this documentation through its [MCP server](https://docs.tagshelf.dev/~gitbook/mcp).

# SDKs

Install the official Alfred SDKs for Python, Node.js and .NET, create a client, make your first call and send your first document in minutes.

Alfred has three official, open-source SDKs: one for Python, one for Node.js and one for .NET. They handle the repetitive parts of an integration for you: sending your credentials, turning failures into typed errors, retrying safe requests where the SDK supports it, and listening to real-time events.

Everything an SDK does is also available through the REST API. Every reference page in these docs shows the request with cURL, so you can mix both, or use the REST API for any call an SDK doesn't have yet.

### Choose your SDK

Pick the language you already work in. The versions below are the ones these docs describe.

| Language                            | Package                      | Version | Needs                                                                                             | Package page                                                        | Source code                                                                           |
| ----------------------------------- | ---------------------------- | ------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| Python                              | `alfred-python`              | 0.7.0   | Python 3.10 or later                                                                              | [PyPI](https://pypi.org/project/alfred-python/)                     | [alfred-python](https://github.com/tagshelfsrl/alfred-python)                         |
| Node.js (JavaScript and TypeScript) | `@tagshelf/alfred`           | 2.0.0   | Node.js 18 or later                                                                               | [npm](https://www.npmjs.com/package/@tagshelf/alfred)               | [alfred-node](https://github.com/tagshelfsrl/alfred-node)                             |
| .NET                                | `TagShelf.Alfred.ApiWrapper` | 0.7.0   | .NET Framework 4.7.2 (`net472`) or any runtime that supports .NET Standard 2.0 (`netstandard2.0`) | [NuGet](https://www.nuget.org/packages/TagShelf.Alfred.ApiWrapper/) | [dotnet-alfred-api-wrapper](https://github.com/tagshelfsrl/dotnet-alfred-api-wrapper) |

### Install

{% tabs %}
{% tab title="Python SDK" %}

```bash
pip install alfred-python
```

The Python SDK needs the `libmagic` system library, which it uses to detect the type of the files you upload. If it's missing, `import alfred.rest` fails, so install it first:

* Debian or Ubuntu: `sudo apt-get install libmagic1`
* macOS: `brew install libmagic`
* Windows: nothing to install; the SDK brings what it needs.
  {% endtab %}

{% tab title="Node.js SDK" %}

```bash
npm install @tagshelf/alfred
```

The package ships with its TypeScript types and works from JavaScript and TypeScript alike. It runs in Node.js, not in a browser.

The Node.js examples in these pages use `import` and top-level `await`. Save them in a file with the `.mjs` extension (for example `first-call.mjs`), or set `"type": "module"` in your `package.json`, and run them with `node first-call.mjs`.
{% endtab %}

{% tab title=".NET SDK" %}

```bash
dotnet add package TagShelf.Alfred.ApiWrapper
```

In Visual Studio's Package Manager Console, run `Install-Package TagShelf.Alfred.ApiWrapper -Version 0.7.0`.

The .NET examples in these pages use top-level statements, so they need a project on C# 9 or later, such as a new .NET console project.
{% endtab %}
{% endtabs %}

### Create a client

Every SDK call goes through a client. Create one with your API key, and keep the key in an environment variable instead of in your code. These examples read it from `ALFRED_API_KEY`. On macOS or Linux, set it with `export ALFRED_API_KEY="<your API key>"`.

{% tabs %}
{% tab title="Python SDK" %}

```python
import os
from alfred.base.config import Configuration
from alfred.http.typed import AuthConfiguration
from alfred.rest import AlfredClient

client = AlfredClient(
    config=Configuration.v1(),
    auth_config=AuthConfiguration({"api_key": os.environ["ALFRED_API_KEY"]}),
)
```

{% endtab %}

{% tab title="Node.js SDK" %}

```javascript
import { AlfredClient, Configuration, Environment } from "@tagshelf/alfred";

const alfred = new AlfredClient(
  Configuration.v1(Environment.Production),
  { apiKey: process.env.ALFRED_API_KEY }
);
```

{% endtab %}

{% tab title=".NET SDK" %}

```csharp
using TagShelf.Alfred.ApiWrapper.Core;

using var alfred = await AlfredFactory.CreateWithApiKeyFromEnvironmentAsync();
```

{% endtab %}
{% endtabs %}

The SDKs send the API key in the `X-TagshelfAPI-Key` header and a `User-Agent` header for you, so you don't have to add either. They talk to `https://app.tagshelf.com` by default.

Prefer another way to sign in? All three SDKs also support OAuth and HMAC signatures. In Python and Node.js you pass `oauth` or `hmac` instead of the API key. In .NET you use `AlfredFactory.CreateWithOAuthAsync` or `AlfredFactory.CreateWithHmacAsync`. How each method works, and when to choose it, is on the [Authentication](https://docs.tagshelf.dev/authentication.md) page.

### Make your first call

Check that your client works with a call that only reads: it lists your 10 most recent jobs. Each snippet is complete, so you can paste it into a file and run it.

{% tabs %}
{% tab title="Python SDK" %}

```python
import os
from alfred.base.config import Configuration
from alfred.http.typed import AuthConfiguration
from alfred.rest import AlfredClient

client = AlfredClient(
    config=Configuration.v1(),
    auth_config=AuthConfiguration({"api_key": os.environ["ALFRED_API_KEY"]}),
)

page = client.jobs.get_all(page_size=10, page=1)
print(page["total"], "jobs")
for job in page["items"]:
    print(job["id"], job["stage"])
```

{% endtab %}

{% tab title="Node.js SDK" %}

```javascript
import { AlfredClient, Configuration, Environment } from "@tagshelf/alfred";

const alfred = new AlfredClient(
  Configuration.v1(Environment.Production),
  { apiKey: process.env.ALFRED_API_KEY }
);

const page = await alfred.jobs.getAll({ page: 1, page_size: 10 });
console.log(page.total, "jobs");
for (const job of page.items) {
  console.log(job.id, job.stage);
}
```

{% endtab %}

{% tab title=".NET SDK" %}

```csharp
using System;
using TagShelf.Alfred.ApiWrapper.Core;
using TagShelf.Alfred.ApiWrapper.Domains.Job.Requests;

using var alfred = await AlfredFactory.CreateWithApiKeyFromEnvironmentAsync();

var page = await alfred.Job.GetAllAsync(new JobListRequest { Page = 1, PageSize = 10 });
Console.WriteLine($"{page.Total} jobs");
foreach (var job in page.Items)
{
    Console.WriteLine($"{job.Id} {job.Stage}");
}
```

{% endtab %}
{% endtabs %}

You should see the number of jobs in your company, followed by one line per job with its ID and stage. A total of `0` is a good result too: it means your key works and you haven't sent a document yet. Seeing a number means you're connected!

If you get an authentication error instead, check that `ALFRED_API_KEY` is set in the same terminal and holds a valid key. The [Handle errors](#handle-errors) section shows how to read the error.

### What each SDK covers

The Node.js and .NET SDKs cover nearly the whole API. The Python SDK covers the calls you need to send documents and read their results.

| API area             | Python SDK | Node.js SDK | .NET SDK |
| -------------------- | ---------- | ----------- | -------- |
| Jobs                 | Partly     | Yes         | Yes      |
| Files                | Partly     | Partly      | Partly   |
| Deferred sessions    | Yes        | Yes         | Yes      |
| Values               | Partly     | Yes         | Yes      |
| Tags                 | No         | Partly      | Partly   |
| Metadata             | No         | Yes         | Yes      |
| Search               | No         | Yes         | Yes      |
| Reports              | No         | Yes         | Yes      |
| Remote sources       | No         | Yes         | Yes      |
| Account and webhooks | No         | Partly      | Yes      |
| Company              | No         | Yes         | Yes      |
| Status               | No         | Yes         | Yes      |

Where an area says "Partly", these calls don't have an SDK method yet:

* **Jobs, Python SDK:** `POST /api/job/bulk-file-operation`.
* **Files, Python SDK:** everything except sending a document by URL, uploading a file into a deferred session, getting a file and downloading it. That leaves out list files, feature, events, versions, package, share, public link, reprocess, reextract and change tag.
* **Files, Node.js SDK:** `GET /api/file/feature/{id}`, `GET /api/file/package/{id}` and `GET /api/file/public/{id}`.
* **Files, .NET SDK:** `GET /api/file/public/{id}`.
* **Values, Python SDK:** `GET /api/values/tag/{id}`.
* **Tags, Node.js and .NET SDKs:** `GET /api/tag/classify`.
* **Account and webhooks, Node.js SDK:** `GET /api/account/companies` and `GET /api/account/tags/{companyId}`. Registering a webhook is covered.

Where an SDK has no call yet, use the REST API for that call. The reference page of each endpoint shows how.

### Send a document and read the results

This is the whole journey in one script: send a document by URL, wait for its job to finish, then read the values Alfred extracted. Alfred works in the background, so the job isn't finished when the upload returns. The examples check the job's stage every few seconds. Prefer not to poll? See [Receive events in real time](#receive-events-in-real-time).

The [Quick start](https://docs.tagshelf.dev/quick-start.md) walks through the same steps one at a time, including uploading a file from your computer.

{% tabs %}
{% tab title="Python SDK" %}

```python
import os
import time

from alfred.base.config import Configuration
from alfred.http.typed import AuthConfiguration
from alfred.rest import AlfredClient

STOPPED = {"completed", "failed", "invalid", "canceled", "expired"}

client = AlfredClient(
    config=Configuration.v1(),
    auth_config=AuthConfiguration({"api_key": os.environ["ALFRED_API_KEY"]}),
    http_config={"timeout": 60},
)

# 1. Send the document
result = client.files.upload({
    "url": "https://example.com/invoices/INV-1042.pdf",
    "correlation_id": "erp:invoice:INV-1042",
})
job_id = result["job_id"]
print("job:", job_id)

# 2. Wait for the job
summary = client.jobs.get(job_id)
while summary["stage"] not in STOPPED:
    print("stage:", summary["stage"])
    time.sleep(5)
    summary = client.jobs.get(job_id)

# 3. Read the values
if summary["stage"] != "completed":
    print("The job ended as", summary["stage"])
else:
    job = client.jobs.get(job_id, view="full", exclude=["fileUrls", "errorMessages"])
    for f in job["files"]:
        if not f.get("is_processing_unit", True):   # a split parent or a page of a group
            continue
        print(f["file_name"], f.get("tag_name"))
        for v in client.data_points.get_values(f["id"]) or []:
            print(" ", v["field_key"], v["value"], v["classification_score"])
```

{% endtab %}

{% tab title="Node.js SDK" %}

```javascript
import {
  AlfredClient, Configuration, Environment, NotFoundError,
} from "@tagshelf/alfred";

const alfred = new AlfredClient(
  Configuration.v1(Environment.Production),
  { apiKey: process.env.ALFRED_API_KEY }
);
const stopStages = ["completed", "failed", "invalid", "canceled", "expired"];

// 1. Send the document
const { job_id } = await alfred.files.upload({
  url: "https://example.com/invoices/INV-1042.pdf",
  correlation_id: "erp:invoice:INV-1042",
});
console.log("job:", job_id);

// 2. Wait for the job
let job = await alfred.jobs.get(job_id);
while (!stopStages.includes(job.stage)) {
  console.log("stage:", job.stage);
  await new Promise((resolve) => setTimeout(resolve, 5000));
  job = await alfred.jobs.get(job_id);
}

// 3. Read the values
if (job.stage !== "completed") {
  console.log("The job ended as", job.stage);
} else {
  const full = await alfred.jobs.get(job_id, { view: "full" });
  for (const file of full.files ?? []) {
    if (!file.is_processing_unit) continue;
    console.log(file.file_name, file.tag_name);
    try {
      for (const v of await alfred.dataPoints.getValues(file.id)) {
        console.log(" ", v.field_key, v.value, v.classification_score);
      }
    } catch (error) {
      if (!(error instanceof NotFoundError)) throw error;
      console.log("  (no extracted values for this file)");
    }
  }
}
```

{% endtab %}

{% tab title=".NET SDK" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using AlfredApiWrapper.Domains.File.Requests;
using TagShelf.Alfred.ApiWrapper.Core;
using TagShelf.Alfred.ApiWrapper.Domains.Job.Results;

using var alfred = await AlfredFactory.CreateWithApiKeyFromEnvironmentAsync();
var stopStages = new HashSet<string> { "completed", "failed", "invalid", "canceled", "expired" };

// 1. Send the document
var upload = await alfred.File.UploadAsync(new UploadRequest
{
    Url = "https://example.com/invoices/INV-1042.pdf",
    CorrelationId = "erp:invoice:INV-1042"
});
Console.WriteLine($"job: {upload.JobId}");

// 2. Wait for the job
var summary = await alfred.Job.GetSummaryAsync(upload.JobId);
while (!stopStages.Contains(summary.Stage))
{
    Console.WriteLine($"stage: {summary.Stage}");
    await Task.Delay(TimeSpan.FromSeconds(5));
    summary = await alfred.Job.GetSummaryAsync(upload.JobId);
}

// 3. Read the values
if (summary.Stage != "completed")
{
    Console.WriteLine($"The job ended as {summary.Stage}");
}
else
{
    var job = await alfred.Job.GetAsync(upload.JobId);
    foreach (var file in job.Files ?? new List<JobFileDetail>())
    {
        if (!file.IsProcessingUnit) continue;
        Console.WriteLine($"{file.FileName} {file.TagName}");
        try
        {
            foreach (var v in await alfred.DataPoint.GetValuesAsync(file.FileId))
            {
                Console.WriteLine($"  {v.FieldKey} {v.Value} {v.ClassificationScore}");
            }
        }
        catch (ApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
        {
            Console.WriteLine("  (no extracted values for this file)");
        }
    }
}
```

{% endtab %}
{% endtabs %}

The job's full view lists its files, and it needs an API key or an Account Admin, so it works with the key you created above. Alfred can split a file into separate documents, so read values from the files whose `is_processing_unit` is `true`. A file only has values once it's finished and its tag has data points set to be extracted. Otherwise Alfred answers `404`, and the examples treat that as nothing extracted for the file.

### Handle errors

When Alfred answers with an error, or doesn't answer at all, each SDK raises its own error type, so you can catch exactly the failures you care about. Each error carries what Alfred said, so you can decide what to do next.

{% tabs %}
{% tab title="Python SDK" %}

```python
from alfred.exceptions import (
    AlfredApiError, AlfredError, AlfredNotFoundError, AlfredPermissionError,
    AlfredRateLimitError, AlfredRequestError,
)

try:
    job = client.jobs.get("7a1d5c3e-9b2f-4e8a-8c61-3f2b9d0e4a17", view="full")
except AlfredNotFoundError:
    job = None                                  # 404: no such job
except AlfredPermissionError as err:            # 403: for example, the full view isn't allowed
    print(err.status_code, err.message)
except AlfredRateLimitError as err:             # 429, after the SDK's own retries
    print("retry after", err.retry_after)
except AlfredApiError as err:                   # any other 4xx or 5xx
    print(err.status_code, err.message, err.reason, err.errors)
except AlfredRequestError as err:               # timeout or connection failure: no status code
    print("no answer:", err)
except AlfredError as err:
    print("SDK error:", err)
```

List the specific errors before `AlfredApiError`. `AlfredApiError` carries `status_code`, `message`, `reason` and `errors`. It also has a `correlation_id`: that's a reference for Tagshelf support about the failed call, not the `correlation_id` of a job.
{% endtab %}

{% tab title="Node.js SDK" %}

```javascript
import {
  AlfredError, BadRequestError, HTTPError, NotFoundError, PermissionError,
  RateLimitError, RequestError, TimeoutError,
} from "@tagshelf/alfred";

try {
  const job = await alfred.jobs.get("7a1d5c3e-9b2f-4e8a-8c61-3f2b9d0e4a17", { view: "full" });
  console.log(job.stage);
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log("No such job.");
  } else if (error instanceof PermissionError) {
    console.error("Not allowed:", error.message);
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Retry in ${error.retryAfter ?? 60} seconds.`);
  } else if (error instanceof BadRequestError) {
    console.error("Invalid request:", error.message, error.errors ?? [], error.reason);
  } else if (error instanceof HTTPError) {
    console.error(error.status, error.method, error.url, error.message);
  } else if (error instanceof TimeoutError) {      // check before RequestError
    console.error("Alfred did not answer in time.");
  } else if (error instanceof RequestError) {
    console.error("Could not reach Alfred:", error.code);
  } else if (error instanceof AlfredError) {
    console.error(error.name, error.message);
  } else {
    throw error;
  }
}
```

HTTP errors (`HTTPError` and its subclasses) carry `status`, `message`, `reason` and `errors`. They also have a `correlationId`: that's a reference for Tagshelf support about the failed call, not the `correlation_id` of a job.
{% endtab %}

{% tab title=".NET SDK" %}

```csharp
using System;
using System.Net;
using System.Threading.Tasks;
using TagShelf.Alfred.ApiWrapper.Core;

try
{
    var job = await alfred.Job.GetAsync(Guid.Parse("7a1d5c3e-9b2f-4e8a-8c61-3f2b9d0e4a17"));
    Console.WriteLine(job.Stage);
}
catch (ApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
    Console.Error.WriteLine("No such job.");
}
catch (ApiException ex) when (ex.StatusCode == (HttpStatusCode)429)
{
    var wait = ex.RetryAfter?.Delta ?? TimeSpan.FromSeconds(5);
    Console.Error.WriteLine($"Rate limited, retry in {wait.TotalSeconds:0} s");
}
catch (ApiException ex)
{
    // StatusCode is null for network failures
    Console.Error.WriteLine($"{(int?)ex.StatusCode} {ex.Error}: {ex.ErrorMessage}");
}
catch (TaskCanceledException)
{
    Console.Error.WriteLine("The request timed out.");
}
```

An `ApiException` carries the `StatusCode` (empty for network failures), the `Error` and `ErrorMessage` from Alfred's answer, and `RetryAfter` for a `429`. Downloading a file with `alfred.File.DownloadAsync` raises an `HttpRequestException` instead of an `ApiException`, so catch that one for downloads.
{% endtab %}
{% endtabs %}

For the status codes and messages of the API itself, see [API conventions](https://docs.tagshelf.dev/endpoints/api-conventions.md).

### Receive events in real time

Polling works, but Alfred can also tell you the moment something happens. The real-time client keeps a connection open and calls your function for every job and file event of your company, such as a job finishing or a file being done. It's the SDK way to follow the events described in the [Event API](https://docs.tagshelf.dev/event-api.md).

A few things to know before you start:

* The real-time client signs in with an API key only, and you pass the key to it explicitly.
* You receive every event of your company. Filter inside your function by `job_id`, `correlation_id` or `file_id`.
* Events aren't replayed. If your connection drops, read the job again with the REST API to see where it stands.
* In Python the connection runs on background threads that do not keep the script alive, so the script must block, as `rt.socket.wait()` does in the example, or it exits and drops the connection. In Node.js the open connection keeps the program running until you close it.

{% tabs %}
{% tab title="Python SDK" %}

```python
import os
from alfred.base.config import Configuration
from alfred.base.constants import JobEvent
from alfred.http.typed import AuthConfiguration
from alfred.realtime import AlfredRealTimeClient

def on_job_event(data):
    print(data.get("event_name"), data.get("job_id"), data.get("correlation_id"), data.get("stage"))

def on_job_finished(data):
    print("finished:", data["job_id"])

rt = AlfredRealTimeClient(
    Configuration.v1(),
    AuthConfiguration({"api_key": os.environ["ALFRED_API_KEY"]}),
    error_callback=lambda err: print("connection attempt failed:", err),
    on_connect=lambda: print("connected"),
)
rt.on_job_event(on_job_event)
rt.on(JobEvent.JOB_FINISHED_EVENT, on_job_finished)

try:
    rt.socket.wait()          # keeps the script alive while connected
except KeyboardInterrupt:
    pass
finally:
    rt.disconnect()
```

The client connects as soon as you create it. If the connection fails, it calls `error_callback` and then raises `alfred.exceptions.ConnectionError`.
{% endtab %}

{% tab title="Node.js SDK" %}

```javascript
import { AlfredEvent, AlfredRealTimeClient, Configuration, Environment } from "@tagshelf/alfred";

const realtime = new AlfredRealTimeClient(
  Configuration.v1(Environment.Production),
  process.env.ALFRED_API_KEY ?? ""
);

realtime.onConnect(() => console.log("connected"));
realtime.onConnectError((err) => console.error("connection problem:", err.message));
realtime.onError((err) => console.error("handler failed:", err.message));

// Every job event, told apart by event_name
realtime.onJobEvent((event) => {
  if (event.event_name === AlfredEvent.JobStageUpdate) {
    console.log("stage:", event.job_id, event.stage);
  } else if (event.event_name === AlfredEvent.JobFinished) {
    console.log("finished:", event.job_id, event.correlation_id);
  }
});

// One kind of file event
realtime.on(AlfredEvent.FileDone, (event) => {
  console.log("file done:", event.file_id, event.job_id, event.tag_name);
});

await realtime.waitUntilConnected();   // rejects after 10 seconds by default
// When you're done: realtime.disconnect();
```

{% endtab %}

{% tab title=".NET SDK" %}

```csharp
using System;
using TagShelf.Alfred.ApiWrapper.Core;
using TagShelf.Alfred.ApiWrapper.RealTime;

var key = Environment.GetEnvironmentVariable("ALFRED_API_KEY")
    ?? throw new InvalidOperationException("Set ALFRED_API_KEY first.");

using var socket = AlfredFactory.CreateRealTimeClient(key);
socket.Connected += (_, __) => Console.WriteLine("connected");
socket.Disconnected += (_, reason) => Console.WriteLine($"disconnected: {reason}");
socket.Error += (_, message) => Console.Error.WriteLine(message);

socket.OnJobEvent(evt => Console.WriteLine($"job {evt.JobId}: {evt.EventName}"));
socket.On(RealTimeChannels.FileEvent, FileEventNames.FileDone,
    evt => Console.WriteLine($"file {evt.FileId} done (job {evt.JobId})"));

await socket.ConnectAsync();
try { Console.ReadLine(); }                   // keep listening until you press Enter
finally { await socket.DisconnectAsync(); }
```

Register your handlers before you call `ConnectAsync`.
{% endtab %}
{% endtabs %}

The events themselves, with their names and fields, are on the [Event API](https://docs.tagshelf.dev/event-api.md) page. Note that a job that is canceled has the stage `canceled`, and its event is named `alfred_event_job_cancelled`.

### Timeouts and retries

Here is what to expect from each SDK out of the box.

|                                   | Python SDK                                                                                                                                                                                      | Node.js SDK                                                                                   | .NET SDK                                         |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| Timeout                           | 5 seconds to connect and 5 seconds to read a response                                                                                                                                           | 60 seconds for ordinary calls; no timeout for file uploads and downloads unless you set one   | 100 seconds (the .NET default); not configurable |
| Automatic retries                 | Up to 3 retries for reads and other safe requests (`GET`, `HEAD`, `PUT`, `DELETE`)                                                                                                              | Up to 2 retries, for `GET` requests only                                                      | None                                             |
| Retried when                      | The answer is `429`, `500`, `502`, `503` or `504`, or the connection could not be opened. Reads (`GET`, `HEAD`, `PUT`, `DELETE`) are also retried after a read timeout or a dropped connection. | The answer is `429`, `502`, `503` or `504`, or the request fails on the network or times out  | Not applicable                                   |
| `Retry-After` header              | Respected                                                                                                                                                                                       | Respected, up to 30 seconds                                                                   | Available as `RetryAfter` on the error           |
| Creating jobs and uploading files | Never retried once the request was sent. A connection that could not be opened is retried, because nothing was sent.                                                                            | Never retried                                                                                 | Never retried                                    |
| How to change it                  | `http_config={"timeout": 60, "max_retries": 3}` when you create the client                                                                                                                      | `{ timeout: 120000, maxRetries: 2 }` as the third argument of `AlfredClient`, in milliseconds | Not available                                    |

What this means for you:

* **Python uploads:** the 5-second default is short for a large file. Raise the timeout when you create the client, as the examples above do with `http_config={"timeout": 60}`.
* **A request that times out:** if a job creation or an upload times out, don't resend it straight away, because Alfred may have received it. Look for the job first with the job list filtered by your `correlation_id` (see [Correlation IDs](https://docs.tagshelf.dev/correlation-ids.md)). Alfred doesn't treat a `correlation_id` as unique, so a second send makes a second job.
* **Rate limits:** when you get a rate-limit error, wait for the time the error gives you (`retry_after`, `retryAfter` or `RetryAfter`) before you try again.

### Upgrading

Coming from an earlier version? These are the changes to make. Each SDK also has its own upgrade notes.

#### Python SDK 0.6 to 0.7

* `client.jobs.get(job_id)` now returns the job's summary. If your code reads `files`, `metadata`, `file_urls` or `error_messages`, pass `view="full"`.
* `client.jobs.get_all()` now returns `items`, `page`, `page_size`, `total` and `has_more`. Code that read `["result"]` should read `["items"]`.
* Errors are typed (see [Handle errors](#handle-errors)), and Python 3.10 or later is required.

Details: "Upgrading from 0.6.x" in the [jobs guide](https://github.com/tagshelfsrl/alfred-python/blob/master/docs/jobs.md), and the [changelog](https://github.com/tagshelfsrl/alfred-python/blob/master/CHANGELOG.md).

#### Node.js SDK 1.x to 2.0

* Data now keeps the API's own `snake_case` names: `job_id` instead of `jobId`, `session_id` instead of `sessionId`. This applies to answers, real-time events and request options. Your `metadata` keys are no longer renamed either.
* `alfred.jobs.get(id)` now returns the summary. For `files`, `metadata`, `file_urls` and `error_messages`, pass `{ view: "full" }`. `alfred.jobs.getAll` returns `items`, `page`, `page_size`, `total` and `has_more`.
* Errors are typed classes, calls time out after 60 seconds, and `GET` requests are retried. Real-time event dates are text in ISO 8601 format, not `Date` objects.

The old camelCase request options still work for now, with a deprecation warning, and stop working in the next major version. Details: the [migration guide](https://github.com/tagshelfsrl/alfred-node/blob/master/docs/migrating-to-v2.md).

#### .NET SDK 0.6 to 0.7

* `alfred.Job.GetAsync` keeps returning the full job, and now asks for it explicitly, which needs an API key or an Account Admin. To follow a job's progress, use `alfred.Job.GetSummaryAsync`.
* Job lists come back as pages with `Items` and `HasMore`.
* A job's priority is no longer set to normal for you. Leave it empty and your account's default applies.

Details: "Upgrading from 0.6.x" in the [REST guide](https://github.com/tagshelfsrl/dotnet-alfred-api-wrapper/blob/master/docs/rest.md).

### More in each repository

Each SDK repository has a `docs` folder with guides written for that SDK.

* **Python:** [docs](https://github.com/tagshelfsrl/alfred-python/tree/master/docs) has guides for getting started, authentication, configuration, jobs, files, sessions, data points, errors, real-time events and compatibility.
* **Node.js:** [docs](https://github.com/tagshelfsrl/alfred-node/tree/master/docs) has a guide for each area (jobs, files, data points, document types, search, sources, account, sessions), plus authentication, configuration, errors, real-time events, webhooks, enums, compatibility and the migration guide.
* **.NET:** [docs](https://github.com/tagshelfsrl/dotnet-alfred-api-wrapper/tree/master/docs) has guides for authentication, the REST calls and real-time events.

Found a problem or have a question about an SDK? Open an issue in its repository.

### What's next

* [Quick start](https://docs.tagshelf.dev/quick-start.md): your first integration, step by step.
* [Authentication](https://docs.tagshelf.dev/authentication.md): API keys, OAuth and HMAC signatures.
* [Event API](https://docs.tagshelf.dev/event-api.md): every job and file event, and how to receive them.
* [Correlation IDs](https://docs.tagshelf.dev/correlation-ids.md): tie your own reference to a job and find it again.
* [API conventions](https://docs.tagshelf.dev/endpoints/api-conventions.md): headers, responses, errors and rate limits shared by every endpoint.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tagshelf.dev/sdks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
