Create a collective / shared temporary access key
Generates one shared guest credential spanning multiple doors. Each door is opened by slide-to-open ('key'), by the key's PIN at a connected entrance panel ('code'), or either ('both'). If any door is code/both, ONE PIN is minted for the whole key and returned here — this response is the only place it is ever returned in the clear. The caller must be authorized for every lock included.
curl -X POST "https://api.spkey.co/temp-keys" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN (JWT)" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"validFrom": "2024-12-25T10:00:00Z",
"validUntil": "2024-12-25T10:00:00Z",
"description": "example_string",
"doors": [
{
"lockId": "null",
"label": "example_string",
"accessMethod": "key"
}
]
}'
import requests
import json
url = "https://api.spkey.co/temp-keys"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN (JWT)",
"X-API-Key": "YOUR_API_KEY"
}
data = {
"validFrom": "2024-12-25T10:00:00Z",
"validUntil": "2024-12-25T10:00:00Z",
"description": "example_string",
"doors": [
{
"lockId": "null",
"label": "example_string",
"accessMethod": "key"
}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.spkey.co/temp-keys", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN (JWT)",
"X-API-Key": "YOUR_API_KEY"
},
body: JSON.stringify({
"validFrom": "2024-12-25T10:00:00Z",
"validUntil": "2024-12-25T10:00:00Z",
"description": "example_string",
"doors": [
{
"lockId": "null",
"label": "example_string",
"accessMethod": "key"
}
]
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"validFrom": "2024-12-25T10:00:00Z",
"validUntil": "2024-12-25T10:00:00Z",
"description": "example_string",
"doors": [
{
"lockId": "null",
"label": "example_string",
"accessMethod": "key"
}
]
}`)
req, err := http.NewRequest("POST", "https://api.spkey.co/temp-keys", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN (JWT)")
req.Header.Set("X-API-Key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.spkey.co/temp-keys')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN (JWT)'
request['X-API-Key'] = 'YOUR_API_KEY'
request.body = '{
"validFrom": "2024-12-25T10:00:00Z",
"validUntil": "2024-12-25T10:00:00Z",
"description": "example_string",
"doors": [
{
"lockId": "null",
"label": "example_string",
"accessMethod": "key"
}
]
}'
response = http.request(request)
puts response.body
{
"success": true,
"uuid": "example_string",
"url": "example_string",
"validFrom": "example_string",
"validUntil": "example_string",
"doors": [
{
"id": 3.14,
"lockId": "example_string",
"lockUuid": "example_string",
"label": "null",
"accessMethod": "key"
}
],
"pin": "null"
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Forbidden",
"message": "You don't have permission to access this resource",
"code": 403
}
{
"error": "Not Found",
"message": "The requested resource was not found",
"code": 404
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred on the server",
"code": 500,
"requestId": "req_1234567890"
}
{
"error": "Service Unavailable",
"message": "The service is temporarily unavailable. Please try again later",
"code": 503
}
/temp-keys
Target server for requests. Edit to use your own host.
JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.
API key for B2B organization access. Provided during organization onboarding.
The media type of the request body
Doors/rooms/zones included in this shared credential
Request Preview
Response
Response will appear here after sending the request
Authentication
Bearer token (JWT). JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.
API Key for authentication. API key for B2B organization access. Provided during organization onboarding.
Body
Doors/rooms/zones included in this shared credential