# Quota

Read credit usage and its history.

## GET /v1/quota

Get quota

```bash
curl -H "x-api-key: $PHI_KEY" https://api.dynophi.com/v1/quota
```

Returns 200 or 422.

### 200 response (application/json)

### 200 response fields and schema

```json
{
  "$ref": "#/$defs/QuotaResponse",
  "$defs": {
    "AutoReloadSummary": {
      "type": "object",
      "required": [
        "enabled",
        "threshold_credits",
        "amount_cents"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "threshold_credits": {
          "type": "integer"
        },
        "amount_cents": {
          "type": "integer"
        }
      }
    },
    "CreditsBlock": {
      "type": "object",
      "required": [
        "allowance",
        "allowance_available",
        "purchased",
        "total_available",
        "reset_at",
        "auto_reload"
      ],
      "properties": {
        "allowance": {
          "type": "integer"
        },
        "allowance_available": {
          "type": "integer"
        },
        "purchased": {
          "type": "integer"
        },
        "total_available": {
          "type": "integer"
        },
        "reset_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "auto_reload": {
          "$ref": "#/$defs/AutoReloadSummary"
        }
      }
    },
    "QuotaResponse": {
      "type": "object",
      "required": [
        "organization_id",
        "credits_limit",
        "credits_reserved",
        "credits_consumed",
        "credits_available",
        "purchased_balance",
        "total_available",
        "plan",
        "plan_source",
        "period_start",
        "period_end",
        "credits"
      ],
      "properties": {
        "organization_id": {
          "type": "string"
        },
        "credits_limit": {
          "type": "integer"
        },
        "credits_reserved": {
          "type": "integer"
        },
        "credits_consumed": {
          "type": "integer"
        },
        "credits_available": {
          "type": "integer"
        },
        "purchased_balance": {
          "type": "integer"
        },
        "total_available": {
          "type": "integer"
        },
        "plan": {
          "type": "string"
        },
        "plan_source": {
          "type": "string"
        },
        "period_start": {
          "type": "string"
        },
        "period_end": {
          "type": "string"
        },
        "credits": {
          "$ref": "#/$defs/CreditsBlock"
        }
      }
    }
  }
}
```

Illustrative response shape. Values are placeholders, not a recorded result.

```json
{
  "organization_id": "<value>",
  "credits_limit": 0,
  "credits_reserved": 0,
  "credits_consumed": 0,
  "credits_available": 0,
  "purchased_balance": 0,
  "total_available": 0,
  "plan": "<value>",
  "plan_source": "<value>",
  "period_start": "<value>",
  "period_end": "<value>",
  "credits": {
    "allowance": 0,
    "allowance_available": 0,
    "purchased": 0,
    "total_available": 0,
    "reset_at": "<value>",
    "auto_reload": {
      "enabled": false,
      "threshold_credits": 0,
      "amount_cents": 0
    }
  }
}
```

## GET /v1/quota/history

Get quota history

```bash
curl -H "x-api-key: $PHI_KEY" https://api.dynophi.com/v1/quota/history
```

### Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| page | query | integer | Optional | 1 | minimum: 1 |
| page_size | query | integer | Optional | 50 | minimum: 1; maximum: 200 |
| cursor | query | string or null | Optional |  | Opaque keyset cursor from a prior X-Next-Cursor header |
| reason | query | (string)[] or null | Optional |  | Keep entries with these reasons only (repeatable) |

Returns 200 or 422.

### 200 response (application/json)

### 200 response fields and schema

```json
{
  "type": "array",
  "items": {
    "$ref": "#/$defs/LedgerEntryResponse"
  },
  "$defs": {
    "PaidWithResponse": {
      "type": "object",
      "properties": {
        "brand": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "last4": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "LedgerEntryResponse": {
      "type": "object",
      "required": [
        "id",
        "run_id",
        "amount",
        "balance_after",
        "reason",
        "pool",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "run_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "amount": {
          "type": "integer"
        },
        "balance_after": {
          "type": "integer"
        },
        "reason": {
          "type": "string"
        },
        "pool": {
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "run_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "pipeline_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "receipt_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "paid_with": {
          "anyOf": [
            {
              "$ref": "#/$defs/PaidWithResponse"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  }
}
```

Illustrative response shape. Values are placeholders, not a recorded result.

```json
[
  {
    "id": "<value>",
    "run_id": "<value>",
    "amount": 0,
    "balance_after": 0,
    "reason": "<value>",
    "pool": "<value>",
    "created_at": "<value>",
    "run_name": "<value>",
    "pipeline_type": "<value>",
    "note": "<value>",
    "receipt_url": "<value>",
    "paid_with": {
      "brand": "<value>",
      "last4": "<value>"
    }
  }
]
```

## GET /v1/quota/months

Get quota months

The ledger by calendar month, newest first: what finished runs used (``RUN_COMPLETED``), what was
added by purchases and grants, and how many runs finished. Reservations and their returns net out of
the month and are not counted.

```bash
curl -H "x-api-key: $PHI_KEY" https://api.dynophi.com/v1/quota/months
```

### Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| limit | query | integer | Optional | 24 | minimum: 1; maximum: 120 |

Returns 200 or 422.

### 200 response (application/json)

### 200 response fields and schema

```json
{
  "type": "array",
  "items": {
    "$ref": "#/$defs/MonthResponse"
  },
  "$defs": {
    "MonthResponse": {
      "type": "object",
      "description": "One calendar month (UTC) of the ledger: what finished runs used and what was added.",
      "required": [
        "month",
        "used",
        "added",
        "runs"
      ],
      "properties": {
        "month": {
          "type": "string"
        },
        "used": {
          "type": "integer"
        },
        "added": {
          "type": "integer"
        },
        "runs": {
          "type": "integer"
        }
      }
    }
  }
}
```

Illustrative response shape. Values are placeholders, not a recorded result.

```json
[
  {
    "month": "<value>",
    "used": 0,
    "added": 0,
    "runs": 0
  }
]
```


---
Source: https://dynophi.com/docs/api/quota. From phi-api 0.2.2, 2026-11-23.
