Manage physical keys 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 a user's physical key, such as a card, through the API:
- List the encoders configured in Salto Space.
- Assign a new key to a user at an encoder.
- Update a user's key with their latest access.
- Cancel a user's key.
You can use any HTTP client, such as Postman, or your own application. To assign or update a key, present the card at the encoder while the request runs.
Before you start, follow the guide to connect Salto Space to the Space API. 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 for the requests shown here. The user must already exist in Salto Space with the access you want to write to the key. See Manage users.
Step 1: Find the encoder
Use the
GET /api/v1/encodersendpoint to list the encoders configured in Salto Space. To limit the number of results, add themaxRowsquery parameter.Copy the
EncoderIdof the encoder where the card is presented, as the response shows it, including any spaces. Each encoder in the response also has aTypeand anIpAddress:json{ "Data": [ { "EncoderId": "ENCODER_ID", "Type": "1", "IpAddress": "0.0.0.0" } ], "Success": true, "Message": "OK" }
Step 2: Assign a new key at the encoder
Use the
POST /api/v1/keys/AssignNewKeyendpoint to assign a new key to a user. The following payload shows the fields:json{ "extUserId": "EXTERNAL_USER_ID", "encoderId": "ENCODER_ID", "timeoutSeconds": 30, "returnRomCode": true, "skipKeyRemoval": false }extUserIdis the external ID of the user who receives the key.encoderIdis the ID of the encoder you copied in Step 1.timeoutSecondsis how long the encoder waits for a card before the operation times out.returnRomCodereturns the ROM code of the card in the response when set totrue.skipKeyRemovalskips the key-removal step at the end of the operation when set totrue.
Present the card at the encoder before the timeout ends. The encoder writes the user's current access to the card, and the API responds when the card is written. When you set
returnRomCodetotrue, the response contains the ROM code of the card:json{ "Data": { "ExtUserId": "EXTERNAL_USER_ID", "RomCode": "ROM_CODE" }, "Success": true, "Message": "OK" }Confirm that the user has the key. When you get the user with the
GET /api/v1/users/IDendpoint,CurrentRomCodecontains the ROM code of the card. In Salto Space, the user page shows the key status bar with the Update key and Cancel key buttons.
Step 3: Update the key with the latest access
When a user's access changes, for example after you assign a new user access level, rewrite their key so it carries the latest access.
- Use the
POST /api/v1/keys/UpdateCurrentKeyendpoint with the same payload as in Step 2. - Present the user's card at the encoder before the timeout ends.
The encoder rewrites the card with the user's latest access.
The response has the same format as in Step 2, and
RomCodeisnullwhen you setreturnRomCodetofalse.
Step 4: Cancel the key
Use the
POST /api/v1/keys/CancelKeyendpoint, with the user's external ID in theextUserIdquery parameter, to cancel the user's key. This request has no body, and the response contains only theSuccessflag and theMessage.After a successful response, the key can no longer open any access point. When you get the user,
CurrentRomCodeisnull. In Salto Space, the user page shows the Assign key button instead of the key status bar.
This request cancels the user's key whether it is a physical or a mobile key.
It is the same operation as the PUT /api/v1/MobileKeys/CancelUserKey endpoint in Manage JustIN Mobile keys.
Handling responses
Every endpoint returns HTTP 200, including when the operation does not succeed.
The response body carries a Success flag and a Message, so always check the Success flag rather than the HTTP status code to determine the outcome.
For example, if the encoderId doesn't match an encoder in Salto Space, the API returns HTTP 200 with Success set to false:
{
"Data": null,
"Success": false,
"Message": "One or more errors occurred. (Ship error 400: Unknown peripheral)"
}API definition and documentation
See the Space API reference 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.