# Add a shopper and record their consent

Create the shopper identity the portals use, keep its details current, record the consent they actually gave and the withdrawal the moment it comes — consent records are legal facts.

Customers · a play in 4 steps.

## The steps

1. Create the shopper profile. — [createConsumer](/reference/consumer/createConsumer/)
2. Edit the profile — the change takes effect immediately and writes a revision. — [updateConsumer](/reference/consumer/updateConsumer/)
3. Record the consent the shopper gave — only what was actually given — and a withdrawal the moment it comes. — [grantConsent](/reference/selling/grantConsent/), [withdrawConsent](/reference/selling/withdrawConsent/)
4. Read the decisions as they stand — one row per shopper per purpose. — [consentRecords](/reference/consent-record/consentRecords/)

## The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

### createConsumer

[createConsumer](/reference/consumer/createConsumer/) — mutation · Create a new consumer profile — the shopper identity used by portals at your organization.

**Example request**

```graphql
mutation ExampleCreateConsumer($input: NewConsumerInput!) {
  createConsumer(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    email
    displayName
    phones
    priceGroupId
    tagIds
    locale
    displayCurrency
    dateOfBirth
    commsFrequency
    commsFormat
    commsTopics
    interests
    preferredLogicalFacilityId
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "email": "<the person’s email address>"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "createConsumer": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CN-EXMP-0000-000F",
      "type": "Consumer",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "email": "<the person’s email address>",
      "displayName": "Blue jeans",
      "phones": [
        "<phones>"
      ],
      "priceGroupId": "01900000-0000-7000-8000-c7ffbf680000",
      "tagIds": [
        "01900000-0000-7000-8000-decd62770000"
      ],
      "locale": "en-CA",
      "displayCurrency": "<display currency>",
      "dateOfBirth": "<date of birth>",
      "commsFrequency": "<comms frequency>",
      "commsFormat": "<comms format>",
      "commsTopics": [
        "<comms topics>"
      ],
      "interests": [
        "<interests>"
      ],
      "preferredLogicalFacilityId": "01900000-0000-7000-8000-23734f810000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### updateConsumer

[updateConsumer](/reference/consumer/updateConsumer/) — mutation · Edit a consumer profile — the shopper identity used by portals — change its details.

**Example request**

```graphql
mutation ExampleUpdateConsumer($id: ID!, $revision: ID!, $input: EditConsumerInput!) {
  updateConsumer(id: $id, revision: $revision, input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    email
    displayName
    phones
    priceGroupId
    tagIds
    locale
    displayCurrency
    dateOfBirth
    commsFrequency
    commsFormat
    commsTopics
    interests
    preferredLogicalFacilityId
  }
}
```

Variables:

```json
{
  "id": "01900000-0000-7000-8000-37386ae00000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "input": {
    "caption": "Blue jeans"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "updateConsumer": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CN-EXMP-0000-000F",
      "type": "Consumer",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "email": "<the person’s email address>",
      "displayName": "Blue jeans",
      "phones": [
        "<phones>"
      ],
      "priceGroupId": "01900000-0000-7000-8000-c7ffbf680000",
      "tagIds": [
        "01900000-0000-7000-8000-decd62770000"
      ],
      "locale": "en-CA",
      "displayCurrency": "<display currency>",
      "dateOfBirth": "<date of birth>",
      "commsFrequency": "<comms frequency>",
      "commsFormat": "<comms format>",
      "commsTopics": [
        "<comms topics>"
      ],
      "interests": [
        "<interests>"
      ],
      "preferredLogicalFacilityId": "01900000-0000-7000-8000-23734f810000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### grantConsent

[grantConsent](/reference/selling/grantConsent/) — mutation · Record a customer’s consent (marketing, data use) as staff, on their word.

**Example request**

```graphql
mutation ExampleGrantConsent($input: ConsentDecisionInput!) {
  grantConsent(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    purposeId
    policyVersion
    captureSurface
    captureLocale
  }
}
```

Variables:

```json
{
  "input": {
    "consumerId": "01900000-0000-7000-8000-6e8c92ec0000",
    "purposeId": "01900000-0000-7000-8000-3e56c4740000",
    "policyVersion": "<policy version>",
    "captureSurface": "<capture surface>",
    "captureLocale": "<capture locale>"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "grantConsent": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CD-EXMP-0000-000F",
      "type": "ConsentRecord",
      "caption": "Blue jeans",
      "status": "granted",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "purposeId": "01900000-0000-7000-8000-3e56c4740000",
      "policyVersion": "<policy version>",
      "captureSurface": "<capture surface>",
      "captureLocale": "<capture locale>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### withdrawConsent

[withdrawConsent](/reference/selling/withdrawConsent/) — mutation · Record a customer withdrawing a consent, as staff.

**Example request**

```graphql
mutation ExampleWithdrawConsent($input: ConsentDecisionInput!) {
  withdrawConsent(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    purposeId
    policyVersion
    captureSurface
    captureLocale
  }
}
```

Variables:

```json
{
  "input": {
    "consumerId": "01900000-0000-7000-8000-6e8c92ec0000",
    "purposeId": "01900000-0000-7000-8000-3e56c4740000",
    "policyVersion": "<policy version>",
    "captureSurface": "<capture surface>",
    "captureLocale": "<capture locale>"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "withdrawConsent": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CD-EXMP-0000-000F",
      "type": "ConsentRecord",
      "caption": "Blue jeans",
      "status": "granted",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "purposeId": "01900000-0000-7000-8000-3e56c4740000",
      "policyVersion": "<policy version>",
      "captureSurface": "<capture surface>",
      "captureLocale": "<capture locale>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### consentRecords

[consentRecords](/reference/consent-record/consentRecords/) — query · The consent record list — each entry is one customer’s decision on one consent purpose — a legal fact.

**Example request**

```graphql
query ExampleConsentRecords($limit: Int) {
  consentRecords(limit: $limit) {
    items {
      id
      sysId
      type
      caption
      status
      parentId
      rootId
      createdAt
      updatedAt
      revisionNum
      revision
      purposeId
      policyVersion
      captureSurface
      captureLocale
    }
    nextToken
  }
}
```

Variables:

```json
{
  "limit": 1
}
```

**Example response**

```json
{
  "data": {
    "consentRecords": {
      "items": [
        {
          "id": "01900000-0000-7000-8000-37386ae00000",
          "sysId": "CD-EXMP-0000-000F",
          "type": "ConsentRecord",
          "caption": "Blue jeans",
          "status": "granted",
          "parentId": "01900000-0000-7000-8000-065235280000",
          "rootId": "01900000-0000-7000-8000-a093dd800000",
          "createdAt": "2027-01-31T00:00:00.000Z",
          "updatedAt": "2027-01-31T00:00:00.000Z",
          "revisionNum": 1,
          "revision": "01900000-0000-7000-8000-b7960e180000",
          "purposeId": "01900000-0000-7000-8000-3e56c4740000",
          "policyVersion": "<policy version>",
          "captureSurface": "<capture surface>",
          "captureLocale": "<capture locale>"
        }
      ],
      "nextToken": "<the cursor from the previous page>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```
