POST /patrons – REST API

Create a Patron: POST /patrons

Create a completely new patron in the account.

URL Parameters
Values should be paramaterized such as using http_build_query() as per example below. Only two fields are required to create a new patron: first_name and last_name.

  • first_name: REQUIRED – Patron’s first name.
  • last_name: REQUIRED – Patron’s last name.
  • email: Patron’s email, must be unique.
  • password: Patron’s password, needed to log into the patron page and check out / hold items.
  • notification_emails: Optional emails which overrides the email field only for sending out notifications. Up to 3 emails allowed, comma separated.
  • tags: Create tags for a patron, comma separated.
  • patron_id: Any ID that you wish to assign, does not need to be unique.
  • phone: Patron’s phone number.
  • address1: Patron’s address.
  • address2: Patron’s address.
  • city: Patron’s city.
  • state: If country is set to US, the state MUST be the two character abbreviation.
  • country: The valid 2 character abbreviation of the patron’s country. Defaults to US.
  • zip: Patron’s zip code.
  • freeze: Set to 1 to freeze patron.
  • barcode: THIS SHOULD GENERALLY NOT BE USED! Libib will automatically create a custom barcode for each patron. If a barcode is included in the parameters, it will be used to create the new patron. However, the barcode you create may not work with our system and we can not provide support for it. A possible use case for this field is if you need to re-instate a deleted patron and want to use their previously assigned barcode. 5-15 digits.
Barcodes are always auto-assigned by Libib. Overriding this behavior by assigning your own barcodes often prevents Libib from working as expected. Libib is unable to support any issues that arise from using non-supported barcodes.

JSON Result Details
Password is never returned in result set.

  • barcode: The barcode – assigned automatically by Libib unless specifically overwritten.
  • first_name: Patron’s first name.
  • last_name: Patron’s last name.
  • email: Patron’s email.
  • notification_emails: Optional emails which overrides the email field only for sending out notifications. Up to 3 emails allowed, comma separated.
  • patron_id: Any ID that you may have assigned.
  • tags: Any tags assigned to patron, comma separated.
  • phone: Patron’s phone number.
  • address1: Patron’s address
  • address2: Patron’s address.
  • city: Patron’s city.
  • state: If country is set to US, the state will be a two character abbreviation.
  • country: The 2 character abbreviation of the country.
  • zip: Patron’s zip code.
  • freeze: 1 if frozen, otherwise null.
<?php
$curl = curl_init();

$params = array(
  'first_name' => 'Mary',
  'last_name' => 'Shelley',
  'email' => 'frankenstein@example.com',
  'notification_email' => 'frankenstein@example.com,another.email@example.com',
  'password' => '2ab3940as94ikd2394k'
);

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.libib.com/patrons?" . http_build_query($params),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_CONNECTTIMEOUT => 5,
  CURLOPT_TIMEOUT => 15,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER =>> array(
    "x-api-key: YOUR_API_KEY",
    "x-api-user: YOUR_API_USER"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  $obj = json_decode($response);
}
{
    "barcode": "2020000000051",
    "first_name": "Mary",
    "last_name": "Shelley",
    "email": "frankenstein@example.com",
    "notification_emails": "frankenstein@example.com,another.email@example.com",
    "tags": null,
    "patron_id": null,
    "phone": null,
    "address1": null,
    "address2": null,
    "city": null,
    "state": null,
    "country": "US",
    "zip": null,
    "freeze": null
}
Updated on March 10, 2024
Was this article helpful?

Related Articles