<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# Get a milestone schema

`GET https://marketplace-api.sequifi.com/v1/milestones/{id}`

Module: Milestones · operationId: `getMilestoneSchema` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/get-milestone-schema

Returns one milestone schema by its schema `id`, with its milestones in order and its linked products. The path takes the schema id. The ids inside `data.schema.milestones[]` are the milestone ids that `POST /v1/sales` expects as `milestone_id`.

**What happens:**

- Read-only. Returns the same fields as one item of `GET /v1/milestones`, under `data.schema`, with no paging fields.
- `products[]` includes past product links with an effective date of today (UTC) or earlier, so a product can appear under more than one schema.

**Errors:**

- `400 Invalid milestone id`: the id is not a positive number. The id is read up to the first non-digit, so `12abc` is read as `12`.
- `400 Cannot use query parameters when fetching a single milestone by id`: any query parameter was sent.
- `401`: missing, invalid or expired token. The body is `{"message": "Unauthorized"}`.
- `404 Milestone not found`: no schema has this id.

**Common mistakes:**

- Sending this schema `id` as `milestone_dates[].milestone_id`. Send `data.schema.milestones[].id`.

**Related:**

- `GET /v1/milestones?product=<id>`: find the schema for a product.
- `POST /v1/sales`: send milestone dates.

## Path parameters

- `id` (integer, **required**): The schema `id` from `GET /v1/milestones`. Not a milestone id. Minimum: 1. Example: `3`.

## Example request

```bash
curl -X GET "https://marketplace-api.sequifi.com/v1/milestones/3" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN"
```

## Responses

### 200: The schema.

- `status` (integer): The HTTP status code, repeated. Example: `200`.
- `message` (string): Short text. Wording varies by endpoint; branch on the HTTP status, not on this text. Example: `success`.
- `data` (object)
  - `requestedBy` (string): Name of the API credential that made the call.
  - `schema` (object): A milestone schema (payment plan) with its milestones in order and its linked products.
    - `id` (integer): Schema id. Use it with `GET /v1/milestones/{id}`. Do not send it as a `milestone_id`.
    - `prefix` (string): Prefix for the milestone codes.
    - `schema_name` (string): Schema name.
    - `schema_description` (string, nullable): Schema description.
    - `status` (string): `"1"` active, `"0"` inactive. A string. One of: `1`, `0`.
    - `milestone_trigger_count` (integer): Number of milestones in the schema.
    - `products` (array of object): Products linked to the schema with an effective date of today (UTC) or earlier, including past links. Deleted products are left out.
      - `id` (integer): Product `id`, the value `POST /v1/sales` accepts as `product_id`.
      - `name` (string): Product name.
    - `milestones` (array of object): The schema's milestones in order.
      - `id` (integer): Milestone id. Send it as `milestone_dates[].milestone_id` on `POST /v1/sales`.
      - `code` (string): The schema `prefix` plus `order`, for example `M1`.
      - `name` (string): Milestone name.
      - `trigger_date_label` (string): Label of the date that triggers the milestone.
      - `order` (integer): Position in the schema, starting at 1.

```json
{
  "status": 200,
  "message": "success",
  "data": {
    "requestedBy": "acme",
    "schema": {
      "id": 3,
      "prefix": "M",
      "schema_name": "Solar Standard",
      "schema_description": "Paid at site survey and at install",
      "status": "1",
      "milestone_trigger_count": 2,
      "products": [
        {
          "id": 12,
          "name": "Solar Rooftop"
        }
      ],
      "milestones": [
        {
          "id": 41,
          "code": "M1",
          "name": "Site Survey",
          "trigger_date_label": "Site Survey Date",
          "order": 1
        },
        {
          "id": 42,
          "code": "M2",
          "name": "Install",
          "trigger_date_label": "Install Date",
          "order": 2
        }
      ]
    }
  }
}
```

### 400: Invalid id, or query parameters sent with the id.

Example (invalid_id): The id is not a positive number

```json
{
  "status": 400,
  "message": "Invalid milestone id",
  "data": {}
}
```

### 401: Missing, invalid or expired token. The body has only `message`.

```json
{
  "message": "Unauthorized"
}
```

### 404: No schema has this id.

```json
{
  "status": 404,
  "message": "Milestone not found",
  "data": {}
}
```

### 500: Server error.

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```
