---
title: "Create project machine grant"
method: POST
path: "/orgs/{orgID}/projects/{projectID}/machine-grants"
tags: ["Machines"]
---

# Create project machine grant

`POST /orgs/{orgID}/projects/{projectID}/machine-grants`

## Request

- Base URL: `https://api.omnara.com/v1`
- URL: `https://api.omnara.com/v1/orgs/{orgID}/projects/{projectID}/machine-grants`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `__Host-omnara_session` and API key in header `X-Omnara-Csrf`

Lets a project's agent configs use one BYO machine by name and returns the grant with the machine's record. Pooled machines can't be granted this way and return 404. Idempotency keys are retained only while the grant exists. Retrying creation after the grant is revoked or deleted can recreate it and restore access, including through automatic SDK retries. A replay compares the request with the current grant.

## Path parameters

- `orgID` string, required
- `projectID` string, required

## Headers

- `Idempotency-Key` string

## Request body

- CreateProjectMachineGrantRequest
  - `machine_id` string, required: Machine ID (mch_...).
  - `description` string: Free-form note stored with the grant.
  - `metadata` Metadata: Arbitrary key-value labels stored with the resource.

## Response `200`

Existing project machine grant returned.

- CreateProjectMachineGrantResponse
  - `grant` ProjectMachineGrant, required
    - `id` string, required: Identifies the machine grant.
    - `org_id` string, required: Organization that owns the grant.
    - `project_id` string, required: Project the grant gives access to.
    - `machine_id` string, required: Machine the project's agents may use.
    - `source_kind` 'explicit' | 'pool', required: Whether the grant was made directly or created for a machine from a pool grant.
    - `project_machine_pool_grant_id` string, nullable
    - `description` string, required: Free-form note about the grant; empty if none was set.
    - `metadata` Metadata, required: Key-value metadata attached to the grant.
    - `created_at` string, date-time, required: When the grant was created.
    - `updated_at` string, date-time, required: When the grant last changed.
  - `machine` Machine, required
    - `id` string, required: Identifies the machine.
    - `org_id` string, required: Organization that owns the machine.
    - `source_kind` 'byo' | 'pool', required: Whether the machine is a bring-your-own computer or was created from a machine pool.
    - `machine_pool_id` string, nullable: Machine pool ID (mpo_...).
    - `display_name` string, required: Machine name; agent configs reference a BYO machine by this as machine_name.
    - `description` string, required: Free-form note about the machine; empty if none was set.
    - `provider` string, required: Sandbox provider that hosts a pool machine; byo for bring-your-own machines.
    - `lifecycle_state` 'provisioning' | 'provision_failed' | 'active' | 'deleting' | 'delete_failed' | 'deleted', required: Where the machine is in provisioning or deletion, independent of whether its daemon is connected.
    - `connection_state` 'online' | 'asleep' | 'offline', required: Whether the machine's daemon is connected now; asleep means suspended but able to be woken.
    - `connection_state_reason` string: Why the machine's latest daemon session ended, such as daemon_lease_expired.
    - `last_observed_at` string, date-time, nullable, required
    - `cwd` string, required: Default working directory for processes started on the machine.
    - `env` object, required: Environment variables set for every process started on the machine.
    - `secret_env` object, required: Environment variable names mapped to secrets whose values are injected when processes start.
    - `lifecycle_reason_code` string, required: Machine-readable reason for the latest lifecycle change, such as idle_timeout; empty when none.
    - `lifecycle_reason_message` string, required: Human-readable detail for lifecycle_reason_code; empty when none.
    - `failure_report` MachineFailureReport: Latest setup or daemon failure reported from the machine; omitted when none is recorded.
      - `stage` 'startup_script' | 'daemon_install' | 'daemon_update' | 'daemon_runtime' | 'daemon_uninstall' | 'daemon_uninstalled', required: Setup or daemon step that failed.
      - `exit_status` integer: Exit status of the failed startup script or daemon install; omitted for other stages.
      - `output_tail` string, required: End of the failed step's output, for diagnosis.
      - `output_truncated` boolean, required: True when earlier output was dropped or output capture failed.
      - `daemon_version` string: Daemon version that was running when a daemon update failed.
      - `target_version` string: Version the daemon was trying to update to when the update failed.
      - `reported_at` string, date-time, required: When the failure was reported.
    - `next_reconcile_after` string, date-time, nullable, required
    - `provision_attempts` integer, required: Number of times Omnara has tried to provision this machine.
    - `delete_attempts` integer, required: Number of times Omnara has tried to delete this machine.
    - `metadata` Metadata, required: Key-value metadata attached to the machine.
    - `deleted_at` string, date-time, nullable, required
    - `created_at` string, date-time, required: When the machine record was created.
    - `updated_at` string, date-time, required: When the machine record last changed.

## Other responses

- `201`: Project machine grant created.
- `400`: The request was invalid.
- `401`: Authentication is required or invalid.
- `403`: The authenticated principal is not authorized.
- `404`: The requested resource was not found or is not visible.
- `409`: The request conflicts with current resource state or idempotency history.
- `503`: The service dependency required to satisfy the request is unavailable.
- `4XX`: Any other client error. The body carries the shared Error envelope restricted to client error codes; statuses with a dedicated response above are documented precisely.
- `5XX`: Any other server error. The body carries the shared Error envelope restricted to server error codes.

## Changes

- **2026-10-05** `3d9e2cf46e07`: 159 info
  - added the optional property `current_digest` to the response with the `400` status
  - added the optional property `current_digest` to the response with the `401` status
  - added the optional property `current_digest` to the response with the `403` status
  - added the optional property `current_digest` to the response with the `404` status
  - …155 more
  - …this revision’s changelog is incomplete
- **2026-09-28** `acddeb8fc6a5`: 7 warning, 7 info
  - added the new `upstream_unavailable` enum value to the `code` response property for the response status `400`
  - added the new `upstream_unavailable` enum value to the `code` response property for the response status `401`
  - added the new `upstream_unavailable` enum value to the `code` response property for the response status `403`
  - added the new `upstream_unavailable` enum value to the `code` response property for the response status `404`
  - …10 more
- **2026-09-17** `eab8138e750d`: 2 warning
  - added the new `daemon_runtime` enum value to the `machine/failure_report/stage` response property for the response status `200`
  - added the new `daemon_runtime` enum value to the `machine/failure_report/stage` response property for the response status `201`
- **2026-09-01** `e4978b047d7a`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/omnara/apis/omnara-api-2/changes/orgs/:orgID/projects/:projectID/machine-grants/post.md)

---

[API](https://skmtc.dev/omnara/apis/omnara-api-2.md) - [All operations](https://skmtc.dev/omnara/apis/omnara-api-2/llms.txt) - [OpenAPI document](https://skmtc.dev/omnara/apis/omnara-api-2/revisions/343aebb1dff1?raw)
