# Plans

## Get plans

<mark style="color:blue;">`GET`</mark> `https://api.petje.af/v1/pages/:pageId/plans`

This endpoint allows you to get the plans that belongs to the selected page.\
\
Scope: `pages.read`

#### Path Parameters

| Name   | Type   | Description                             |
| ------ | ------ | --------------------------------------- |
| pageId | string | ID of the page that the plans belong to |

#### Query Parameters

| Name     | Type    | Description                                    |
| -------- | ------- | ---------------------------------------------- |
| rewardId | string  | Filter the results by this Reward ID           |
| limit    | string  | The number of plans to return                  |
| from     | boolean | Offset the results after the plan with this ID |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Access token using the `Bearer` method |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{
    "count": 3,
    "_embedded": {
        "plans": [
            {
                "resource": "plans",
                "id": "AUmpLHxzVEU3R57RtFxM",
                "name": "Klein petje",
                "amount": 3,
                "interval": "month",
                "intervalLabel": "publicatie",
                "rewards": [
                    {
                        "id": "6JGhzAiPD7jqlbYkdrg8",
                        "name": "Dit is een beloning",
                        "type": "default"
                    },
                    {
                        "id": "8igf2PLGpYjLLJp3NaTB",
                        "name": "Instagram account",
                        "type": "instagram"
                    }
                ],
                "status": "enabled",
                "_links": {
                    "self": {
                        "href": "https://api.petje.af/pages/5SaEUOWD2b4dN7tJBKMB/plans/AUmpLHxzVEU3R57RtFxM",
                        "type": "application/hal+json"
                    },
                    "page": {
                        "href": "https://api.petje.af/pages/5SaEUOWD2b4dN7tJBKMB",
                        "type": "application/hal+json"
                    },
                    "rewards": {
                        "href": "https://api.petje.af/pages/5SaEUOWD2b4dN7tJBKMB/rewards?planId=AUmpLHxzVEU3R57RtFxM",
                        "type": "application/hal+json"
                    }
                }
            },
            ...
        ]
    },
    "_links": {
        "self": {
            "href": "https://api.petje.af/plans",
            "type": "application/hal+json"
        },
        "next": null
    }
}
```

{% endtab %}
{% endtabs %}

## Get plan detail

<mark style="color:blue;">`GET`</mark> `https://api.petje.af/v1/pages/:pageId/plans/:id`

Scope: `pages.read`

#### Path Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| pageId | string | The page ID |
| id     | string | The plan ID |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Access token using the `Bearer` method |

{% tabs %}
{% tab title="200 " %}

```
{
    "resource": "plans",
    "id": "AUmpLHxzVEU3R57RtFxM",
    "name": "Klein petje",
    "amount": 3,
    "interval": "month",
    "intervalLabel": "publicatie",
    "status": "enabled",
    "_links": {
        "self": {
            "href": "https://api.petje.af/pages/5SaEUOWD2b4dN7tJBKMB/plans/AUmpLHxzVEU3R57RtFxM",
            "type": "application/hal+json"
        },
        "page": {
            "href": "https://api.petje.af/pages/5SaEUOWD2b4dN7tJBKMB",
            "type": "application/hal+json"
        },
        "rewards": {
            "href": "https://api.petje.af/pages/5SaEUOWD2b4dN7tJBKMB/rewards?planId=AUmpLHxzVEU3R57RtFxM",
            "type": "application/hal+json"
        }
    }
}
```

{% endtab %}

{% tab title="404 " %}

```
{
    "status": 404,
    "title": "Not Found",
    "detail": "Plan is not found",
    "_links": {
        "documentation": {
            "href": "https://docs.petje.af",
            "type": "text/html"
        }
    }
}
```

{% endtab %}
{% endtabs %}
