# Manage JustIN Mobile keys with the Salto Space API
> How to assign and cancel JustIN Mobile keys and send JustIN Mobile SDK audit trails with the Salto Space API.


The Space API, part of Salto IDM Connect, is a REST API that communicates with your Salto Space installation over the SHIP protocol.
This guide explains how to manage users and their JustIN Mobile keys through the API:

- Create a user with the values required for mobile key assignment.
- Get and assign user access levels to the user.
- Assign a JustIN Mobile or JustIN Mobile SDK key to the user.
- Cancel the mobile key of the user.
- Delete the user.
- Assign and cancel a mobile key that is not tied to a user, directly to a phone number.
- Send the audit trail of JustIN Mobile SDK openings to Salto Space.

The examples use Postman, but you can use any HTTP client or your own application.

{{% info-panel %}}
Before you start, follow the guide to [connect Salto Space to the Space API](https://support.saltosystems.com/idm/connect/space-api/connect-salto-space/).
That guide explains how Salto connects the Space API to your Salto Space installation and issues the API credentials you need.
Then [request an access token](/space/space-api/authentication) for the requests shown here.
{{% /info-panel %}}

## Step 1: Create a user with the values required for mobile assignment {#step-1-create-a-user-with-the-values-required-for-mobile-assignment}

1. Use the `POST /api/v1/users` endpoint to create a user, or the `PUT /api/v1/users/ID` endpoint to update an existing one.
The following payload shows the minimal requirements for mobile key assignment:

    ```json
    {
      "extUserId": "UNIQUE_USER_ID",
      "firstName": "FIRST_NAME",
      "lastName": "LAST_NAME",
      "phoneNumber": "PHONE_NUMBER",
      "mobileAppType": 3,
      "keyRevalidationEnabled": 1,
      "keyRevalidationPeriod": 7,
      "keyRevalidationPeriodUnit": 0
    }
    ```

    - `extUserId` is the unique identifier of the user in Salto Space.
    You can provide any string.
    - `phoneNumber` is required and must not be assigned to any other user.
    Use the full phone number including the country code, for example `+15555550100`.
    - `mobileAppType` sets the key type: use `2` for JustIN Mobile keys or `3` for JustIN Mobile SDK keys.
    - `keyRevalidationEnabled` must be `1`.
    Set `keyRevalidationPeriod` to the minimum period your configuration requires, for example 7 days (`keyRevalidationPeriodUnit` of `0`).

    The following example creates a user that uses a JustIN Mobile SDK key:

    ![Postman POST request creating a user with a JustIN Mobile SDK key.](images/create-user.png)
    {.border}

    The following example updates a user to use a JustIN Mobile key:

    ![Postman PUT request updating a user to use a JustIN Mobile key.](images/update-user.png)
    {.border}

2. After a successful call, confirm that the user was created in Salto Space.

    ![New user shown on the identification page in Salto Space.](images/space-user-created.png)
    {.border}

3. Check that the key revalidation period, mobile app type, and phone number are correct.

    ![User key expiration and mobile phone settings in Salto Space.](images/space-user-key-settings.png)
    {.border}

{{% info-panel %}}
This example provides only the minimal fields required to create a user and assign a mobile key.
See the [Space API reference](https://space.api.saltoidm.app/) for the other fields you can set on the users you manage.
{{% /info-panel %}}

## Step 2: Get and assign user access levels {#step-2-get-and-assign-user-access-levels}

1. Get the list of available user access levels using the `GET /api/v1/accesslevels` endpoint.
To get zones, use the `GET /api/v1/zones` endpoint.

    ![Postman GET request returning the available user access levels.](images/get-access-levels.png)
    {.border}

2. Find the user access level you want to assign and copy its `extGroupId`.
For zones, copy the `extZoneId`.
3. Use the `POST` or `PUT` endpoint for users and provide the list of access levels in the `groupMembership` property.
For zones, use the `zoneAccessRights` property.

    ```json
    {
      "groupMembership": [
        { "extGroupId": "ACCESS_LEVEL_ID" }
      ]
    }
    ```

    ![Postman PUT request assigning a user access level through group membership.](images/assign-access-level.png)
    {.border}

4. After a successful response, confirm that the user access levels are assigned to the user in Salto Space.

    ![Assigned user access level shown in Salto Space.](images/space-user-access-levels.png)
    {.border}

## Step 3: Assign a JustIN Mobile or JustIN Mobile SDK key {#step-3-assign-a-justin-mobile-or-justin-mobile-sdk-key}

After the user exists in Salto Space with access levels or zones assigned, assign a JustIN Mobile key.
Choose the mobile app type for your use case:

- Use **JustIN Mobile** for users who open locks with Salto's JustIN Mobile app.
Use the `PUT /api/v1/MobileKeys/AssignUserMobileKey` endpoint to assign the key.

    ![Postman PUT request assigning a JustIN Mobile key.](images/assign-mobile-key.png)
    {.border}

- Use **JustIN Mobile SDK** for users who open locks with your own app.
Use the `PUT /api/v1/MobileKeys/AssignUserMobileKeySdk` endpoint to obtain the `BinaryData` string, then integrate it into your app using the JustIN Mobile SDK.

    ![Postman PUT request assigning a JustIN Mobile SDK key and returning the binary data.](images/assign-mobile-key-sdk.png)
    {.border}

1. Confirm that the key is assigned by checking the key status on the user page in Salto Space.

    ![Assigned mobile key status shown on the user page in Salto Space.](images/space-user-key-assigned.png)
    {.border}

2. If you used JustIN Mobile, the user receives a notification that a new key is available and can use it by opening the JustIN Mobile app.

    ![JustIN Mobile notification that a new key is available.](images/justin-app-new-key.png)
    {.border}

    ![JustIN Mobile app showing the available key.](images/justin-app-key.png)
    {.border}

## Step 4: Cancel the mobile key of the user {#step-4-cancel-the-mobile-key-of-the-user}

1. To cancel a JustIN Mobile key, whether regular or SDK, use the `PUT /api/v1/MobileKeys/CancelUserKey` endpoint.

    ![Postman PUT request canceling the user mobile key.](images/cancel-key.png)
    {.border}

    - If you use the JustIN Mobile app, the key is removed from the app automatically.
    - If you use the SDK, the key stops working, but you must handle the removal process in your app as well.

    The `POST /api/v1/keys/CancelKey` endpoint performs the same operation.
    Both cancel the user's key whether it is a mobile or a physical key.

2. In Salto Space, the key status banner at the top of the user page is removed, and the **Mobile app** field becomes editable again.

    ![User page in Salto Space after the mobile key is canceled.](images/space-user-key-canceled.png)
    {.border}

3. If you use JustIN Mobile, the key is removed from the app automatically.

    ![JustIN Mobile app showing no keys after cancellation.](images/justin-app-no-keys.png)
    {.border}

## Step 5: Delete the user {#step-5-delete-the-user}

1. To fully delete the user instead of only canceling the mobile key, use the `DELETE /api/v1/users/ID` endpoint.

    ![Postman DELETE request removing the user.](images/delete-user.png)
    {.border}

2. After the user is deleted, the record is removed from Salto Space and all access is revoked, including both mobile and physical keys.

    ![Cardholder not found error in Salto Space confirming the user was deleted.](images/space-user-deleted.png)
    {.border}

{{% info-panel %}}
Cancel the mobile key first, and then delete the user.
This is recommended but not mandatory.
It prevents undesired scenarios when you use the JustIN Mobile SDK.
{{% /info-panel %}}

## Step 6: Assign a non-user mobile key {#step-6-assign-a-non-user-mobile-key}

You can also assign a JustIN Mobile key that is not tied to a user, directly to a phone number.
Use this when you want to issue a key to a phone number without creating and maintaining a cardholder in Salto Space.

1. Use the `POST /api/v1/mobilekeys/assignNonUserMobileKey` endpoint.
Provide the following query parameters:

    - `phoneNumber` is the phone number that receives the key.
    Use the full phone number including the country code, for example `+15555550100`.
    - `keyId` identifies the key.
    - `returnKeyId` controls whether the response returns the resulting key ID.

2. Provide the key configuration in the request body.
The following payload shows the structure:

    ```json
    {
      "generalPeriod": {
        "startDate": { "value": "2026-06-12T00:00:00Z" },
        "endDate": { "value": "2026-12-12T00:00:00Z" }
      },
      "office": "OFFICE",
      "auditOpenings": "AUDIT_OPENINGS",
      "accessRights": [
        {
          "accessPoints": {
            "accessType": 0,
            "accessID": "ACCESS_ID"
          },
          "timezones": [
            {
              "startTime": "08:00",
              "startTimeString": "08:00",
              "endTime": "18:00",
              "endTimeString": "18:00"
            }
          ]
        }
      ]
    }
    ```

    - `generalPeriod` sets the validity window of the key, with a `startDate` and `endDate`.
    - `office` and `auditOpenings` set the office and audit openings for the key.
    - `accessRights` defines what the key opens and when.
    Each entry pairs an `accessPoints` value, which sets the `accessType` and `accessID`, with the `timezones` that apply.

3. After a successful call, the response returns a `Success` flag, a `Message`, and a `Data` value.
When you set `returnKeyId`, the `Data` value carries the resulting key ID, which you use later to cancel the key.

## Step 7: Cancel a non-user mobile key {#step-7-cancel-a-non-user-mobile-key}

1. To cancel a non-user mobile key, use the `PUT /api/v1/mobilekeys/cancelMobileKey` endpoint.
Provide the `keyId` query parameter to identify the key to cancel.

2. After a successful call, the key is canceled and stops working.

{{% info-panel %}}
Non-user mobile keys are assigned to a phone number rather than to a cardholder in Salto Space.
They are identified by their key ID and are managed independently of users, so they do not appear in the user steps shown earlier in this guide.
{{% /info-panel %}}

## Step 8: Send the JustIN Mobile SDK audit trail to Salto Space {#step-8-send-the-justin-mobile-sdk-audit-trail-to-salto-space}

When a device opens a lock over Bluetooth with a JustIN Mobile SDK key, the SDK captures ciphered audit trail data.
Send this data to the API so Salto Space can decipher it and store the resulting event in its database.
This lets your app audit these openings in real time.

1. Use the `POST /api/v1/MobileKeys/DecipherJustInMobileSdkAuditTrail` endpoint with the following payload:

    ```json
    {
      "auditTrailData": "CIPHERED_AUDIT_TRAIL_DATA",
      "showUserIdAs": 1,
      "showDoorIdAs": 1
    }
    ```

    - `auditTrailData` is required and contains the ciphered audit trail data that the JustIN Mobile SDK returned.
    - `showUserIdAs` sets how the response identifies the user: `0` for the user name, which is the default, or `1` for the external user ID.
    - `showDoorIdAs` sets how the response identifies the door: `0` for the door name, which is the default, or `1` for the external door ID.

2. After a successful call, Salto Space stores the event, and the response contains the deciphered event:
    - The date and time of the event.
    - The operation code and its description, such as an opening or a rejection.
    - Whether the event happened at the exit reader.
    - The door and the user, identified as you requested.
    - The battery status of the lock: `0` for normal, `1` for low, or `2` for the lowest level.

## API definition and documentation {#api-definition-and-documentation}

See the [Space API reference](https://space.api.saltoidm.app/) for a full description of the endpoints and entities available through the API.

The Space API uses a limited set of the functionality available in the full SHIP protocol.
Contact `support-id@saltosystems.com` if you need functionality in the API that is not yet available.

The endpoints and their entities are fully described in the Salto Host Interface Protocol (SHIP) specifications document.
To integrate the binary data into your own application for using mobile keys, follow the technical documentation and SDK for the JustIN Mobile SDK.
Salto Identity Solutions does not provide these documents, but you can request them from your Salto dealer or partner, or by contacting `support@saltosystems.com`.

