# Update contacts added by SSO

HTML version: [Update contacts added by SSO](https://support.gladstonesoftware.cloud/sso/sso-auto-provisioning-api-examples)

## Problem
The Single Sign-On (SSO) auto-provisioning feature can create a member/student record when someone signs in to GoBook or GoJoin for the first time using their university Microsoft account. After that first sign-in, a follow-up process will be needed to complete the member/student record: find the new record, read that member's profile, add date of birth, add address details, add contact details, add a member card id, add student identifier to a user field and other similar fields.

## Resolution
The steps below show example API endpoint calls that may be useful when designing this follow-up API flow.

1. **Find records (profiles) created with a specific status and time-frame**
   - Use [List all member profiles with filtering and pagination](../reference/members/list-all-member-profiles-with-filtering-and-pagination.md) to poll the member profile list with a date window and a status filter.
   - The date window on this endpoint is based on the member record's `modifiedOn` value, not specifically on `createdOn`. If you need records created today, use the date window to reduce the result set, then check each returned profile's `createdOn` value before acting on it.

   ```bash title="cURL"
   curl -G '{base_url}/api/members/profiles' \
     -H 'Authorization: Bearer ***' \
     -H 'X-Use-SSO: true' \
     --data-urlencode 'dateFrom=2026-10-02T00:00:00Z' \
     --data-urlencode 'dateTo=2026-10-02T23:59:59Z' \
     --data-urlencode 'statusIds=PROSP' \
     --data-urlencode 'includeContactDetails=true'
   ```

   - Keep paging until the response returns an empty `profiles` array and an empty `continuation-token`. Send the same `dateFrom`, `dateTo`, `statusIds` and `include*` flags on every page, together with the `continuation-token` from the previous response.
   - The `memberId` on each returned profile is the value to pass as `{memberId}` to the per-member calls below.

2. **Read one member profile before updating it**
   - Use [Retrieve a member's basic profile details](../reference/members/retrieve-a-members-basic-profile-details.md) before you update the member. This gives you the current `titleId` and `dateOfBirth`, plus any other fields your integration needs to preserve.

   ```bash title="cURL"
   curl -X GET '{base_url}/api/members/{memberId}/profile?includeStatus=true&includeContactDetails=true' \
     -H 'Authorization: Bearer ***' \
     -H 'X-Use-SSO: true'
   ```

   - Use this response to shape the updates in the following steps.

3. **Update title and date of birth**
   - Use [Update a member's basic profile details](../reference/members/update-a-members-basic-profile-details.md) to set only the profile fields you need to change.
   - `titleId` is the exception to the endpoint's normal partial-update behaviour: omitting it, sending `null`, or sending an empty string resets the member's title to the default `UNKNO`. If you are only changing `dateOfBirth`, send the current `titleId` you read in step 2.

   ```bash title="cURL"
   curl -X PUT '{base_url}/api/members/{memberId}/profile' \
     -H 'Authorization: Bearer ***' \
     -H 'X-Use-SSO: true' \
     -H 'Content-Type: application/json' \
     -d '{
       "titleId": "MR",
       "dateOfBirth": "2004-09-21T00:00:00Z"
     }'
   ```

   - A successful call returns `204 No Content`. Validation is all-or-nothing, so nothing is written when the request fails.

4. **Update member user fields**
   - Use [Update member user fields](../reference/members/update-member-user-fields.md) to add data that is saved as user fields and not part of the fixed member profile. Examples include Student ID, Course, etc.
   - Fetch the definitions first with [Get all user field configurations](../reference/configuration/get-all-user-field-configurations.md), then send the definition ids and values to the member endpoint.

   ```bash title="cURL"
   curl -X PUT '{base_url}/api/members/{memberId}/user-fields' \
     -H 'Authorization: Bearer ***' \
     -H 'X-Use-SSO: true' \
     -H 'Content-Type: application/json' \
     -d '[
       {
         "userFieldId": 1,
         "value": "26049581"
       },
       {
         "userFieldId": 2,
         "value": "Computer Science"
       }
     ]'
   ```

   - This call is a merge, not a replacement. Fields you do not send keep their existing values. The whole array is validated before anything is saved, so one invalid field rejects the entire update.

5. **Add phone number**
   - Use [Update member contact details using JSON Patch](../reference/members/update-member-contact-details-using-json-patch.md) to set the member's mobile phone number with `PATCH /api/members/{memberId}/contact-details`.
   - Contact details are updated with a JSON Patch array. To update the mobile number, replace the fixed `/mobile/number` slot. If the mobile number should also become the member's primary phone number, set `/mobile/isPrimary` to `true` and clear any existing primary phone flag in the same request, because only one of `telephone1`, `telephone2` and `mobile` can be primary.

   ```bash title="cURL"
   curl -X PATCH '{base_url}/api/members/{memberId}/contact-details' \
     -H 'Authorization: Bearer ***' \
     -H 'X-Use-SSO: true' \
     -H 'Content-Type: application/json' \
     -d '[
       {
         "op": "replace",
         "path": "/mobile/number",
         "value": "07123456789"
       },
       {
         "op": "replace",
         "path": "/mobile/isPrimary",
         "value": true
       },
       {
         "op": "replace",
         "path": "/telephone1/isPrimary",
         "value": false
       }
     ]'
   ```

   - A successful call returns `204 No Content`. Telephone numbers are limited to 50 characters and are not format-checked.

6. **Add address details**
   - Use [Update member address details](../reference/members/update-member-address-details.md) to set the member's home address with `PUT /api/members/{memberId}/addresses`.
   - Including an address object replaces that whole address, so send each line you want to keep. Lines omitted from an included address object are saved as empty strings.

   ```bash title="cURL"
   curl -X PUT '{base_url}/api/members/{memberId}/addresses' \
     -H 'Authorization: Bearer ***' \
     -H 'X-Use-SSO: true' \
     -H 'Content-Type: application/json' \
     -d '{
       "address1": {
         "addressLine1": "1 Lupton Road",
         "addressLine2": "",
         "addressLine3": "",
         "townCity": "Wallingford",
         "region": "Oxfordshire",
         "postalCode": "OX10 BT",
         "country": "",
         "isPrimary": true
       }
     }'
   ```

   - A successful call returns `204 No Content`.

## Notes
- This article assumes the member/student already exists because SSO auto-provisioning has created it; it does not cover configuring SSO itself. For that, see the other Single Sign-On articles, such as [How to Configure and Enable Operator SSO Using Microsoft Entra](how-to-configure-and-enable-operator-sso-using-microsoft-entra.md) and [Single Sign-On (SSO): The Consumer SSO Experience](single-sign-on-sso-the-consumer-sso-experience.md).
- Full flow summary:
  1. Use `GET /api/members/profiles` with a date window and `statusIds`. Use the result to filter a record based on `createdOn` values if you need created date rather than merely changed date.
  2. Read a selected record with `GET /api/members/{memberId}/profile`.
  3. Update only the required profile fields, such as date of birth, with `PUT /api/members/{memberId}/profile`, remembering to preserve `titleId` unless you intend to reset it.
  4. Add additional details that need storing in member/student user fields using `PUT /api/members/{memberId}/user-fields`.
  5. Add the member's mobile phone number with `PATCH /api/members/{memberId}/contact-details`.
  6. Add the member's home address with `PUT /api/members/{memberId}/addresses`.
- Each write endpoint validates the request before saving. Treat failures as no-change outcomes unless the endpoint page explicitly says otherwise.
