# Where a Savings Plan purchase stands

> One BUY- purchase: what it buys, the tranche it belongs to, and its latest purchase run with the steps, logs and trigger of its row. execution.status reads as it does for a renewal, plus returned when AWS refunded the plan after it was bought, and cancelled when a plan queued inside AWS was deleted while queued. execution.starts_at is when AWS starts such a plan: only runs sent before LevelFour stopped queueing inside AWS carry either. bought_outside names the plan of the same type and term bought outside LevelFour that stopped the latest run. execution.status reads scheduled while a released purchase waits on LevelFour's side until execution.send_at, and cancelled_before_purchase once it was cancelled before it was sent. execution.can_buy_now and execution.can_cancel say whether the caller may buy it now or cancel it at this moment, by the rules those two routes apply. Reads stored state only and never calls AWS. 404 for an id that is no purchase of this organization.

Source: https://docs.levelfour.ai/api-reference/commitments/get-commitments-purchase-by-id


## GET /api/v1/commitments/purchase/{recommendation_id}

One BUY- purchase: what it buys, the tranche it belongs to, and its latest purchase run with the steps, logs and trigger of its row. execution.status reads as it does for a renewal, plus returned when AWS refunded the plan after it was bought, and cancelled when a plan queued inside AWS was deleted while queued. execution.starts_at is when AWS starts such a plan: only runs sent before LevelFour stopped queueing inside AWS carry either. bought_outside names the plan of the same type and term bought outside LevelFour that stopped the latest run. execution.status reads scheduled while a released purchase waits on LevelFour's side until execution.send_at, and cancelled_before_purchase once it was cancelled before it was sent. execution.can_buy_now and execution.can_cancel say whether the caller may buy it now or cancel it at this moment, by the rules those two routes apply. Reads stored state only and never calls AWS. 404 for an id that is no purchase of this organization.

### Authentication

Send `Authorization: Bearer <token>`.

### Parameters

- `recommendation_id` (path, string, required)

### Responses

#### 200: Successful Response

- `success` (boolean, default `true`)
- `timestamp` (date-time string)
- `data` (object, required)
  - `recommendation_id` (string, required)
  - `payer_account_id` (string, required)
  - `plan_type` (one of `compute`, `database` or `ec2_instance`, nullable, required): Null for a reservation
  - `term_months` (integer, required)
  - `payment_option` (one of `all_upfront`, `partial_upfront`, `no_upfront`, required)
  - `commitment_hourly` (number, nullable, required): Null for a reservation
  - `profile` (one of `conservative`, `balanced`, `max_savings`, nullable, required)
  - `capped_by` (array of string, required)
  - `monthly_savings` (number, required)
  - `grain` (`daily`, nullable, required): Null when no usage was replayed to price the purchase
  - `source` (`cur`, nullable, required)
  - `created_by` (string, nullable)
  - `created_at` (string, required)
  - `rebindable` (boolean, default `false`)
  - `kind` (one of `reserved_instance`, `savings_plan`, nullable): Null on a plan raised from its proposal, before either instrument had terms
  - `origin` (one of `recommended`, `custom`, nullable)
  - `target` (object, nullable): The ReservationTarget or PlanTarget the purchase was raised for
  - `resource` (string, nullable): The class a reservation buys
  - `quantity` (integer, nullable): How many reservations it buys
  - `offering_id` (string, nullable)
  - `quote` (object, nullable): The PurchaseQuoteData it was raised on, without its series
  - `draft` (boolean, default `false`): Raised before anybody asked for a decision on it. A draft is its raiser's alone: out of every list and total until it is accepted or requested
  - `draft_expires_at` (string, nullable): When a draft dies unless it is accepted or requested first. Null for a purchase that is no draft
  - `buying_account_id` (string, required)
  - `schedule_id` (string, nullable)
  - `tranche_number` (integer, nullable)
  - `tranches_total` (integer, nullable)
  - `buy_after_utc` (string, nullable)
  - `verified_active_at` (string, nullable): When the executor saw AWS report the plan active
  - `execution` (object, required)
    - `status` (one of `not_started`, `in_progress`, `active`, `queued`, `payment_failed`, `failed`, `indeterminate`, `scheduled`, `cancelled_before_purchase`, `returned`, `cancelled`, required)
    - `provider_state` (string, nullable): AWS's own state for the plan, once it was sent
    - `purchase_id` (string, nullable): The Savings Plan id AWS answered with
    - `error` (string, nullable)
    - `starts_at` (string, nullable): When AWS starts a plan it was asked to queue. Only purchases sent before LevelFour stopped queueing inside AWS carry one.
    - `send_at` (string, nullable): When LevelFour sends a released purchase to AWS: once its hold ends, or on its scheduled day for a tranche. Until then it reads scheduled, and it can be bought now or cancelled.
    - `can_buy_now` (boolean, default `false`): The caller may end its hold now: an organization admin, on a new purchase released to Automated Savings that is still held and was not sent.
    - `can_cancel` (boolean, default `false`): The caller may cancel it now: an organization admin or the member who raised or requested it, while it was not sent to AWS.
  - `bought_outside` (object, nullable): The plan of the same type and term bought outside LevelFour that stopped this one
    - `plan_id` (string, required)
    - `started_on` (string, nullable)
  - `trigger_info` (object, nullable)
  - `execution_steps` (array of object)
    - `step_id` (string, required)
    - `label` (string, required)
    - `status` (one of `done`, `pending`, `warning`, `in_progress`, `failed`, required)
    - `duration_seconds` (integer, nullable)
    - `parent_step_id` (string, nullable)
  - `execution_logs` (array of object)
    - `step_id` (string, required)
    - `label` (string, required)
    - `status` (one of `done`, `pending`, `warning`, `in_progress`, `failed`, required)
    - `commands` (array of object)
      - `order` (integer, required)
      - `command` (string, required)
      - `output` (string, nullable)

#### Errors

- `400`: Bad Request
- `401`: Authentication Error
- `403`: Authorization Error
- `404`: Not Found
- `409`: Conflict
- `422`: Validation Error
- `429`: Rate Limit Exceeded
- `500`: Internal Server Error

Body of `400`, `401`, `403`, `404`, `409`, `422`, `429`, `500`:

- `success` (`false`, required)
- `error` (object, required)
  - `code` (string, required)
  - `message` (string, required)
  - `details` (any)
- `timestamp` (date-time string, required)
