# Purpose

## Get All Purposes

<mark style="color:blue;">`GET`</mark> `https://api.domain.com/api/services/app/Purposes/GetAll`

ใช้สำหรับแสดงข้อมูลวัตถุประสงค์ทั้งหมดที่ user ที่ทำงานอยู่มีสิทธิ์มองเห็น

#### Query Parameters

| Name   | Type   | Description                                                                          |
| ------ | ------ | ------------------------------------------------------------------------------------ |
| Filter | string | ข้อมูลที่ต้องการ filter ในวัตถุประสงค์ โดยจะค้นหารในชื่อและรายละเอียดของวัตถุประสงค์ |

#### Headers

| Name          | Type   | Description        |
| ------------- | ------ | ------------------ |
| Authorization | string | Bearer tokenของคุณ |

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

```
{
  "result": {
    "totalCount": 0,
    "items": [
      {
        "purpose": {
          "name": "string",
          "description": "string",
          "status": "string",
          "version": 0,
          "expireTime": "2021-03-06T14:51:41.043Z",
          "isSetExpire": true,
          "purposeCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "organizationUnitId": 0,
          "applicationLanguageId": 0,
          "purposeStatusId": 0,
          "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "purposeCategoryName": "string",
        "organizationUnitDisplayName": "string",
        "applicationLanguageName": "string",
        "purposeStatusName": "string"
      }
    ]
  },
  "targetUrl": null,
  "success": true,
  "error": null,
  "unAuthorizedRequest": false,
  "__abp": true
}
```

{% endtab %}
{% endtabs %}

## Get purpose by ID

<mark style="color:blue;">`GET`</mark> `https://api.domain.com/api/services/app/Purposes/GetPurposeForView`

ใช้แสดงรายละเอียดวัตถุประสงค์ตาม ID ที่ระบุมา

#### Query Parameters

| Name | Type   | Description                               |
| ---- | ------ | ----------------------------------------- |
| id   | string | ID ของวัตถุประสงค์ โดยมี format เป็น GUID |

#### Headers

| Name          | Type   | Description        |
| ------------- | ------ | ------------------ |
| Authorization | string | Bearer tokenของคุณ |

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

```
{
  "result": {
    "purpose": {
      "name": "string",
      "description": "string",
      "status": "string",
      "version": 0,
      "expireTime": "2021-03-06T14:58:31.157Z",
      "isSetExpire": true,
      "purposeCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "organizationUnitId": 0,
      "applicationLanguageId": 0,
      "purposeStatusId": 0,
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    },
    "purposeCategoryName": "string",
    "organizationUnitDisplayName": "string",
    "applicationLanguageName": "string",
    "purposeStatusName": "string"
  },
  "targetUrl": null,
  "success": true,
  "error": null,
  "unAuthorizedRequest": false,
  "__abp": true
}
```

{% endtab %}

{% tab title="404 " %}

```
{
  "result": null,
  "targetUrl": null,
  "success": false,
  "error": {
    "code": 0,
    "message": "There is no entity Purpose with id = ",
    "details": null,
    "validationErrors": null
  },
  "unAuthorizedRequest": false,
  "__abp": true
}
```

{% endtab %}
{% endtabs %}

Consent Status

| Status Name | Descriptions                  |
| ----------- | ----------------------------- |
| approved    | เจ้าของข้อมูลให้ความยินยอม    |
| rejected    | เจ้าของข้อมูลไม่ให้ความยินยอม |
| notGiven    | ยังไม่ให้ความยินยอม           |
| withdrawn   | เจ้าของข้อมูลถอนความยินยอม    |
| expired     | ความยินยอมหมดอายุ             |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.reddot.co.th/consent-management-api/purpose-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
