> For the complete documentation index, see [llms.txt](https://help.security.gallagher.com/knowledge-hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.security.gallagher.com/knowledge-hub/products/cc-software/configure/interface-options/api/representational-state-transfer-rest-api/rest-api-cardholder-request-examples.md).

# REST API cardholder request examples

Review worked REST API requests that read and change cardholders, cards and access groups.

Worked examples of common cardholder requests, sent from Postman. `server.example.com` stands for the Command Centre server; the examples use port 8904.

The three methods:

* **GET** retrieves data from the Command Centre server. It is read-only: it has no risk of altering or corrupting the data.
* **POST** sends data to Command Centre and creates a new resource.
* **PATCH** modifies existing data.

Addresses and names on this page are examples.

### Disable or enable a card

1. Use **GET** to query the cardholder's card first.
2. Find the **href** link of the card (not of the card type).

   ![Postman GET /api/cardholders/907: in the response, card 447 of type Desfire with status Active, and the card's href highlighted; the server address is covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-8b5660e403f2a02995dbc75157230aaec758bdbf%2FSECHUB-TS-REST-CARDHOLDER-01-get-card-href.jpg?alt=media)
3. Use **PATCH** to update the existing card. To disable it, send:

   ```json
   {
     "cards": {
       "update": [
         {
           "href": "https://server.example.com:8904/api/cardholders/907/cards/509806bebab0423ab5bc22f052d00b48",
           "status": {
             "value": "Disabled (manually)",
             "type": "inactive"
           }
         }
       ]
     }
   }
   ```

   ![Postman PATCH /api/cardholders/907 with the body above, the card href and the status value Disabled (manually), type inactive, highlighted; the server address is covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-6287e5eda581cf4ea8fda17d368cbc3aa945d60e%2FSECHUB-TS-REST-CARDHOLDER-02-patch-disable-card.jpg?alt=media)

**Result:**

![Event Properties: Operator (name covered) Modified Cardholder "TEST, REST"; Details: Changed: Card 447 ("Desfire"), Changed: "State" from "Active" to "Disabled (manually)"](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-286a08083104b2df482d840a0ecf6ae5b17b46f8%2FSECHUB-TS-REST-CARDHOLDER-03-event-card-disabled.png?alt=media)

![Cardholder REST TEST in Command Centre Client: card 447, Desfire, status Disabled (manually)](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-9bbda991e162c1bbf4bc91df2815b99dcadc0fde%2FSECHUB-TS-REST-CARDHOLDER-04-card-disabled-in-client.jpg?alt=media)

To set the card state back to **Active**, send:

```json
{
  "cards": {
    "update": [
      {
        "href": "https://server.example.com:8904/api/cardholders/907/cards/509806bebab0423ab5bc22f052d00b48",
        "status": {
          "value": "Active",
          "type": "active"
        }
      }
    ]
  }
}
```

### Find the newest cardholders (highest IDs)

* Use **GET** to query the cardholders sorted by ID, highest first: `GET /api/cardholders?sort=-id`

  ![Postman GET /api/cardholders?sort=-id: the results start with ids 925, 907 and 862; the server address and the third cardholder's name are covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-38d29425ab15c96e9418289d20199fd068dc38b1%2FSECHUB-TS-REST-CARDHOLDER-05-sort-highest-id.jpg?alt=media)
* Remove the `-` to show the lowest IDs first: `GET /api/cardholders?sort=id`

  ![Postman GET /api/cardholders?sort=id: the results start with ids 595, 596 and 602; the server address and the cardholders' names are covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-e3fe997c79f7c052653235d043b95f589ddc9d7f%2FSECHUB-TS-REST-CARDHOLDER-06-sort-lowest-id.jpg?alt=media)

### Add an access group to an existing cardholder

1. Find the cardholder's ID.

   ![A test cardholder's properties (name covered) with the FTItemID dialog: ID = 972](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-499a516edb0c67562ebbabd082afa8ff2f09f685%2FSECHUB-TS-REST-CARDHOLDER-07-cardholder-id.jpg?alt=media)
2. Find the **href** link of the access group with **GET**.

   ![Postman GET /api/access\_groups/: access group 684, "Main Site A - Visitor", with its href highlighted, and access group 690, "Visitor A", whose parent is 684; the server address is covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-9ecfd060b5d482cbb9974a6c2fd6976439af7889%2FSECHUB-TS-REST-CARDHOLDER-08-access-group-href.jpg?alt=media)
3. Use **PATCH** on the cardholder to add the access group:

   ```json
   {
     "accessgroups": {
       "add": [
         {
           "accessgroup": {
             "href": "https://server.example.com:8904/api/access_groups/684"
           }
         }
       ]
     }
   }
   ```

   ![Postman PATCH /api/cardholders/972 with the body above; the server address is covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-b82f6944837d81b13026c8fa48f4551f83762e10%2FSECHUB-TS-REST-CARDHOLDER-09-patch-add-access-group.jpg?alt=media)

**Result:**

![Event Properties: a test cardholder (name covered) membership activated for "Main Site A - Visitor"; Details: Access Group Main Site A - Visitor, Activation Time None, Expiry Time None](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-4b9c0fb72cd9878284ce9095c5a4d7d6e9e3a7c1%2FSECHUB-TS-REST-CARDHOLDER-10-event-membership-activated.jpg?alt=media)

### Search existing cardholders by first and last name

* To find an existing cardholder's first name, use **GET**: `https://server.example.com:8904/api/cardholders?fields=firstName&name=samsung`

  ![Postman GET ?fields=firstName\&name=samsung returns firstName "Samsung"; the server address is covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-735026ea156d0392e5804b1ff2296a65c2d5c53f%2FSECHUB-TS-REST-CARDHOLDER-11-search-first-name.jpg?alt=media)

  ![Postman GET ?fields=lastName\&name=samsung returns lastName "Fold"; the server address is covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-93c00f5ace2a7defa9500c0f7d0382530dce2589%2FSECHUB-TS-REST-CARDHOLDER-12-search-last-name.jpg?alt=media)
* To show the cardholders' first and last names:

  ![Postman GET /api/cardholders?fields=firstName,lastName returns a list of firstName and lastName pairs; the server address and the names are covered](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-2dce146990d48960267f3e863076daf0c9ceb488%2FSECHUB-TS-REST-CARDHOLDER-13-fields-first-and-last-name.jpg?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.security.gallagher.com/knowledge-hub/products/cc-software/configure/interface-options/api/representational-state-transfer-rest-api/rest-api-cardholder-request-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
