---
title: Consent API Getting started
description: The following information illustrates how to construct a typical Consent API request.
component: pingdirectory
page_id: pingdirectory:consent:consent-api-getting-started
canonical_url: https://developer.pingidentity.com/pingdirectory/consent/consent-api-getting-started.html
section_ids:
  create-the-api-request-header: Create the API request header
  create-the-api-request-body: Create the API request body
  submit-the-api-request: Submit the API request
  evaluate-the-response: Evaluate the response
---

# Consent API Getting started

The following information illustrates how to construct a typical Consent API request.

## Create the API request header

The API request header contains the authentication information you must provide to make a call to any Consent API resource. The `Authorization` parameter takes the user credentials or the full bearer token as its value, which contains the authorization information needed to access the requested resource.

The following samples show the API request header (`-H 'Authorization: Bearer`) where `accessToken` is a base64url-encoded bearer token.

```none
curl -X "GET" "https://<server>/consent/v1/definitions" \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer accessToken'
```

This request header also shows an additional parameter of note:

* `Content-Type`

  In the header of a `PUT` or `POST` request, this parameter identifies the media type of the request data sent to the server. For most Consent API calls, the Content-Type is `application/json`.

## Create the API request body

The API request body for `POST`, `PATCH`, or `PUT` requests provides the attribute values needed to complete the *create* or *update* operation. For example, to update a consent record, the `PUT` operation requires values for the `attr1` and `attr2` attributes in the request body:

```none
{
  "attr1": "value1",
  "attr2": "value2"
}
```

## Submit the API request

You can use the Consent API to return a list of consent definitions.

The following sample shows the [`GET /definitions`](definitions-api/read-definitions.html) operation to return a list of all consent definitions and their attributes.

```none
curl -X GET "https://<server>/consent/v1/definitions" \
-H "Content-type: application/json" \
-H "Authorization: Bearer accessToken"
```

In the request header, the `Bearer accessToken` value is your full base64url-encoded token generated by the authentication service. If your token is valid, the API request returns a `200: Successful operation` message, and the response data lists all consent definitions.

This `GET` request does not require a request body.

## Evaluate the response

The response returns the list of consent definitions.

```json
{
  "_links": {
    "self": {
      "href": "https://<server>/consent/v1/definitions"
    }
  },
  "_embedded": {
    "definitions": [
      {
        "id": "share-my-email",
        "displayName": "ShareEmail"
        "_links": {
          "self": {
            "href": "https://<server>/consent/v1/definitions/share-my-email"
         }
        }
      }
    ]
  }
  "size": 1,
  "count": 1,
}
```
