# Python SDK

> Run your team's scripts from Python in one call, and call every API operation, typed from the API itself.

The Python SDK is a typed client for Python 3.10 and later. Its `run` method runs a script and returns the result in one call, however long the script takes. Every other API operation is a method too. Each method and response takes its shape from the same definitions the API uses to validate requests, so the SDK always matches the [API reference](/docs/reference/). It depends on httpx and pydantic.

## Install

```bash
pip install reminix
```

## Your key

Create an API key in the app under **Settings → Developers**, and keep its access at **Run scripts**.

* `Reminix()` reads your key from the `REMINIX_API_KEY` environment variable. If you haven’t set it, it reads `REMINIX_TOKEN`, the variable the CLI uses. With neither variable set, it raises an error.
* To pass the key yourself, use `Reminix(api_key=key)`.
* With an **API key**, every call acts in the key’s workspace.
* With a **personal access token**, pass it as `token` and name the workspace: `Reminix(token=token, workspace="acme")`.

## Run a script

```python
from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

run = reminix.run("monthly-report", {"month": "2026-09"})
print(run.output)
```

`run` returns once the script has finished:

* **A long run** keeps going after the API call returns. `run` checks on it until it ends.
* **A run that needs a person’s approval** waits for them. Pass `on_approval` to show them where to approve it: `reminix.run(slug, inputs, on_approval=notify)`.
* **A run that fails or ends as cancelled** raises a `RunError`. A run ends as cancelled when a person stops it, an approver denies it, or its approval expires. The error’s `run` has the run’s `status`, and the run’s `error` says why.
* **To get the run back straight away**, pass `wait=False`. Later, `reminix.wait_for_run(run)` follows it until it ends. It also takes the run’s id.
* **`poll_interval=`** sets how often `run` checks on a run that hasn’t ended, in seconds. It’s 2 by default.
* **`timeout=`** limits each request `run` makes, as on every other method. If a request times out, `run` tries it again.
* **To limit the whole wait**, use `asyncio.timeout()` with `AsyncReminix`. The run carries on when the wait stops.
* **To make calling again safe**, such as from a job that reruns, pass `idempotency_key=`. A second call with the same key and inputs returns the first run instead of starting another.

The inputs are the script’s own fields, with the names the script gives them.

### Files given and saved

Give a file input as a `pathlib.Path`, a file opened with `"rb"`, or a `FileUpload`. The SDK uploads the file first and passes its id. In this example, the monthly report takes an optional CSV file of manual adjustments and saves the report as a CSV file:

```python
from pathlib import Path

from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

run = reminix.run(
    "monthly-report",
    {"month": "2026-09", "adjustments": Path("adjustments.csv")},
)
for file in run.files or []:
    if file.origin == "saved":
        print(file.name, file.download_url)
```

The files a run saves come back in `run.files`, each with a download link. [Files](/docs/files/) has the details.

## Make a call

```python
from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

runs = reminix.runs.list(script="monthly-report", limit=10)
print(runs.items)
```

Every API operation is a method, named after its [CLI](/docs/cli/) command. For example, `reminix runs list` becomes `reminix.runs.list()`.

* Ids in the path are arguments, and everything else is a keyword argument:

  ```python
  reminix.scripts.update("monthly-report", name="Monthly report")
  ```

* Keyword arguments use Python naming, so the API’s `approvalPolicy` becomes `approval_policy=`.

* Creating a schedule or trigger needs a personal access token, not a workspace API key. [Schedules and triggers](/docs/schedules-and-triggers/) explains why.

* Because the types come from the API itself, your editor completes every method, keyword argument and response field.

## Responses

A method returns a model of the response. Its fields are attributes in Python naming, so the API’s `durationMs` is `run.duration_ms`.

```python
from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

run = reminix.runs.get("run_620f14ad-32e8-4f5e-89fd-1c80de7e9124")
print(run.status, run.duration_ms)

print(run.to_dict())  # the API's own field names
print(run.to_json())
```

* `to_dict()` and `to_json()` return the fields the API sent, with the API’s field names.
* The models are in `reminix.types`, such as `reminix.types.Run`. Each one is a pydantic model.
* The SDK keeps a field the API adds later. You can read it by its API name until you update the SDK.
* The SDK also keeps a value it doesn’t know yet, such as a new status, as it came. It never raises an error.
* Timestamps are `datetime` objects.

## Lists

A list method returns its first page. When you iterate over the page, the SDK fetches the next pages as it goes, so the loop sees every item:

```python
from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

for run in reminix.runs.list(script="monthly-report"):
    print(run.id, run.status)
```

To work one page at a time, use the page itself:

```python
from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

page = reminix.runs.list(script="monthly-report", limit=10)
print(page.items, page.next_cursor)
if page.has_next_page():
    page = page.get_next_page()
```

[Pagination](/docs/pagination/) has the details.

## Errors

Every error a call raises is a `ReminixError`. When the API returns an [error](/docs/errors/), the SDK raises an `APIError` of the class for its HTTP status:

| Status       | Error                      |
| ------------ | -------------------------- |
| 400          | `BadRequestError`          |
| 401          | `AuthenticationError`      |
| 402          | `PlanLimitError`           |
| 403          | `PermissionDeniedError`    |
| 404          | `NotFoundError`            |
| 409          | `ConflictError`            |
| 422          | `UnprocessableEntityError` |
| 429          | `RateLimitError`           |
| 500 or above | `InternalServerError`      |
| Any other    | `APIError`                 |

An `APIError` carries these attributes:

| Attribute     | What it holds                                                     |
| ------------- | ----------------------------------------------------------------- |
| `status_code` | The HTTP status.                                                  |
| `code`        | The error’s code, such as `not_found`.                            |
| `message`     | What went wrong.                                                  |
| `request_id`  | The request’s id. Quote it when you contact us.                   |
| `details`     | What was wrong with each field, as `{"path", "message"}` entries. |
| `docs`        | A link to the code’s entry on the Errors page.                    |
| `headers`     | The response’s headers, such as `Retry-After`.                    |

When the SDK can’t reach the API, it raises an `APIConnectionError`. An attempt that runs out of time raises an `APITimeoutError`, a kind of `APIConnectionError`. Either one keeps the network error as its `__cause__`.

A run that fails raises a `RunError`, which is a `ReminixError` too:

```python
from reminix import APIConnectionError, NotFoundError, Reminix, RunError

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

try:
    run = reminix.run("monthly-report", {"month": "2026-09"})
except NotFoundError:
    print("No such script")
except RunError as error:
    print(error.run.error)
except APIConnectionError:
    print("The API couldn't be reached. Try again later.")
```

## Retries and idempotency

The SDK retries a failed attempt twice: after a network error, a timeout, a `408`, a `429`, a `500`, `502`, `503` or `504`, or a `409` with the code `idempotency_in_progress`.

* It waits as long as `Retry-After` asks, up to 60 seconds. When the API asks for longer, the SDK raises the error instead.

* Every write sends an [idempotency key](/docs/idempotency/), the same on each retry, so the write happens only once.

* To make your own retries safe too, pass your key:

  ```python
  from reminix import Reminix

  reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

  run = reminix.runs.create(
      "monthly-report",
      inputs={"month": "2026-09"},
      idempotency_key="monthly-report-2026-09",
  )
  ```

* To change how often it retries, pass `max_retries=` to the client or to `with_options()`.

## Timeouts

Each attempt waits up to 60 seconds for a response. The SDK retries a timed-out attempt with the same key. To change the limit, pass `timeout=` in seconds to the client, to one call, or to `with_options()` for the calls made through it:

```python
from reminix import Reminix

reminix = Reminix()  # uses the REMINIX_API_KEY environment variable

reminix.scripts.get("monthly-report", timeout=5)
reminix.with_options(timeout=5, max_retries=0).scripts.get("monthly-report")
```

To limit a whole `AsyncReminix` call, retries included, wrap it in `asyncio.timeout()`. Past it, the call stops at once, even while it waits to retry, and raises a `TimeoutError`.

## Client options

| Option            | What it does                                                                             |
| ----------------- | ---------------------------------------------------------------------------------------- |
| `api_key`         | Your API key. Without it, `REMINIX_API_KEY`, then `REMINIX_TOKEN`.                       |
| `token`           | A personal access token, used with `workspace`.                                          |
| `workspace`       | The workspace a personal access token acts in.                                           |
| `environment`     | The environment to act in, sent as `X-Environment`. Without it, the workspace’s default. |
| `base_url`        | The API’s address, without `/v1`. Without it, `REMINIX_BASE_URL`, then the live API.     |
| `timeout`         | The seconds each attempt may take. 60 by default.                                        |
| `max_retries`     | How many times to retry a failed attempt. 2 by default.                                  |
| `default_headers` | Headers to send with every call.                                                         |
| `http_client`     | Your own `httpx.Client`, or `httpx.AsyncClient` for `AsyncReminix`.                      |

Every method also takes these keyword arguments:

| Argument          | What it does                                    |
| ----------------- | ----------------------------------------------- |
| `idempotency_key` | Your key for this write. Writes only.           |
| `extra_headers`   | Headers to send with this call only.            |
| `timeout`         | The seconds each attempt of this call may take. |

`with_options()` takes `timeout`, `max_retries` and `default_headers`. It returns the same client with those defaults. Its `default_headers` go with the client’s own, not in place of them.

## Methods

Here is every method. Each one links to its fields and a full example under **Endpoints**:

### Scripts

* [`scripts.archive()`](/docs/reference/scripts/#archive-a-script)

  Archive a script

* [`scripts.create()`](/docs/reference/scripts/#create-a-script)

  Create a script

* [`scripts.get()`](/docs/reference/scripts/#get-a-script)

  Get a script

* [`scripts.list()`](/docs/reference/scripts/#list-scripts)

  List scripts

* [`scripts.restore()`](/docs/reference/scripts/#restore-an-archived-script)

  Restore an archived script

* [`scripts.update()`](/docs/reference/scripts/#change-a-script)

  Change a script

### Runs

* [`runs.cancel()`](/docs/reference/runs/#cancel-a-run)

  Cancel a run

* [`runs.create()`](/docs/reference/runs/#run-a-script)

  Run a script

* [`runs.get()`](/docs/reference/runs/#get-a-run)

  Get a run

* [`runs.list()`](/docs/reference/runs/#list-runs)

  List runs

* [`runs.log()`](/docs/reference/runs/#get-a-runs-log)

  Get a run's log

### Versions

* [`script_versions.get()`](/docs/reference/versions/#get-a-version)

  Get a version

* [`script_versions.list()`](/docs/reference/versions/#list-a-scripts-versions)

  List a script's versions

* [`script_versions.publish()`](/docs/reference/versions/#publish-a-version)

  Publish a version

* [`script_versions.test_run()`](/docs/reference/versions/#test-run-a-version)

  Test-run a version

* [`script_versions.upload()`](/docs/reference/versions/#upload-a-version)

  Upload a version

### Schedules

* [`schedules.create()`](/docs/reference/schedules/#schedule-a-script)

  Schedule a script

* [`schedules.delete()`](/docs/reference/schedules/#delete-a-schedule)

  Delete a schedule

* [`schedules.get()`](/docs/reference/schedules/#get-a-schedule)

  Get a schedule

* [`schedules.list()`](/docs/reference/schedules/#list-a-scripts-schedules)

  List a script's schedules

* [`schedules.update()`](/docs/reference/schedules/#change-a-schedule)

  Change a schedule

### Triggers

* [`triggers.create()`](/docs/reference/triggers/#run-a-script-when-something-happens)

  Run a script when something happens

* [`triggers.delete()`](/docs/reference/triggers/#delete-a-trigger)

  Delete a trigger

* [`triggers.get()`](/docs/reference/triggers/#get-a-trigger)

  Get a trigger

* [`triggers.list()`](/docs/reference/triggers/#list-a-scripts-triggers)

  List a script's triggers

* [`triggers.rotate_secret()`](/docs/reference/triggers/#rotate-a-webhook-triggers-secret)

  Rotate a webhook trigger's secret

* [`triggers.update()`](/docs/reference/triggers/#change-a-trigger)

  Change a trigger

### Files

* [`files.content()`](/docs/reference/files/#get-a-files-content)

  Get a file's content

* [`files.get()`](/docs/reference/files/#get-a-file)

  Get a file

* [`files.list()`](/docs/reference/files/#list-files)

  List files

* [`files.upload()`](/docs/reference/files/#upload-a-file)

  Upload a file

### Environments

* [`environments.create()`](/docs/reference/environments/#add-an-environment)

  Add an environment

* [`environments.delete()`](/docs/reference/environments/#delete-an-environment)

  Delete an environment

* [`environments.get()`](/docs/reference/environments/#get-an-environment)

  Get an environment

* [`environments.list()`](/docs/reference/environments/#list-environments)

  List environments

* [`environments.update()`](/docs/reference/environments/#change-an-environment)

  Change an environment

### Secrets

* [`secrets.delete()`](/docs/reference/secrets/#delete-a-secret)

  Delete a secret

* [`secrets.get()`](/docs/reference/secrets/#get-a-secret)

  Get a secret

* [`secrets.list()`](/docs/reference/secrets/#list-secrets)

  List secrets

* [`secrets.update()`](/docs/reference/secrets/#update-a-secret)

  Update a secret

* [`secret_values.delete()`](/docs/reference/secrets/#remove-a-secrets-value-from-an-environment)

  Remove a secret's value from an environment

* [`secret_values.set()`](/docs/reference/secrets/#save-a-secrets-value)

  Save a secret's value

### Script settings

* [`script_settings.get()`](/docs/reference/script-settings/#get-the-workspaces-script-settings)

  Get the workspace's script settings

* [`script_settings.update()`](/docs/reference/script-settings/#change-the-workspaces-script-settings)

  Change the workspace's script settings

### Trigger calls

* [`trigger_calls.list()`](/docs/reference/trigger-calls/#list-a-webhook-triggers-calls)

  List a webhook trigger's calls

### Workspace

* [`workspace.get()`](/docs/reference/workspace/#get-the-current-workspace)

  Get the current workspace

* [`workspace.invitations.list()`](/docs/reference/workspace/#list-pending-invitations)

  List pending invitations

* [`workspace.members.list()`](/docs/reference/workspace/#list-workspace-members)

  List workspace members

* [`workspace.plan_usage.get()`](/docs/reference/workspace/#get-your-plans-usage-this-period)

  Get your plan's usage this period

* [`workspace.teams.list()`](/docs/reference/workspace/#list-teams)

  List teams

### Webhooks

* [`workspace.event_types.list()`](/docs/reference/webhooks/#list-event-types)

  List event types

* [`workspace.webhook_deliveries.list()`](/docs/reference/webhooks/#list-an-endpoints-deliveries)

  List an endpoint's deliveries

* [`workspace.webhook_deliveries.redeliver()`](/docs/reference/webhooks/#redeliver-an-event)

  Redeliver an event

* [`workspace.webhook_endpoints.create()`](/docs/reference/webhooks/#add-a-webhook-endpoint)

  Add a webhook endpoint

* [`workspace.webhook_endpoints.delete()`](/docs/reference/webhooks/#remove-a-webhook-endpoint)

  Remove a webhook endpoint

* [`workspace.webhook_endpoints.enable()`](/docs/reference/webhooks/#re-enable-a-webhook-endpoint)

  Re-enable a webhook endpoint

* [`workspace.webhook_endpoints.get()`](/docs/reference/webhooks/#get-a-webhook-endpoint)

  Get a webhook endpoint

* [`workspace.webhook_endpoints.list()`](/docs/reference/webhooks/#list-webhook-endpoints)

  List webhook endpoints

* [`workspace.webhook_endpoints.test()`](/docs/reference/webhooks/#send-a-test-event)

  Send a test event

* [`workspace.webhook_endpoints.update()`](/docs/reference/webhooks/#update-a-webhook-endpoint)

  Update a webhook endpoint

### Approvals

* [`workspace.approval_actions.list()`](/docs/reference/approvals/#list-the-actions-you-can-ask-approval-for)

  List the actions you can ask approval for

* [`workspace.approval_requests.create()`](/docs/reference/approvals/#ask-a-person-to-approve-an-action)

  Ask a person to approve an action

* [`workspace.approval_requests.get()`](/docs/reference/approvals/#check-an-approval-request)

  Check an approval request

* [`workspace.approval_requests.redeem()`](/docs/reference/approvals/#redeem-an-approved-request)

  Redeem an approved request

### Audit events

* [`workspace.audit_events.list()`](/docs/reference/audit-events/#list-workspace-audit-events)

  List workspace audit events

### Personal access tokens

* [`user.me()`](/docs/reference/personal-access-tokens/#get-the-current-user)

  Get the current user

* [`user.revoke_token()`](/docs/reference/personal-access-tokens/#revoke-the-token-making-this-request)

  Revoke the token making this request

## Async

`AsyncReminix` has the same methods, and you `await` each call. A list is the exception. You `await` it for its first page, or use `async for` to go through every item:

```python
import asyncio

from reminix import AsyncReminix


async def main() -> None:
    async with AsyncReminix() as reminix:  # uses the REMINIX_API_KEY environment variable
        run = await reminix.run("monthly-report", {"month": "2026-09"})
        print(run.output)

        async for past in reminix.runs.list(script="monthly-report"):
            print(past.id, past.status)


asyncio.run(main())
```

`async with` closes the client when the block ends. Without it, call `await reminix.close()` when you’re done.
