Change a temporary access key
Changes any of the key's validity window, use limit, access mode and whitelist, and guest instructions. Its doors never change. The change is judged against the key as it stands, as a whole. The caller must be authorized for every lock of the key. A revoked key is not found (404); one expired and retired cannot be changed (409).
curl -X PATCH "https://api.spkey.co/temp-keys/example_string" \
-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",
"maxUses": "null",
"accessMode": "public",
"allowedUserIds": [
"example_string"
],
"description": "null"
}'
import requests
import json
url = "https://api.spkey.co/temp-keys/example_string"
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",
"maxUses": "null",
"accessMode": "public",
"allowedUserIds": [
"example_string"
],
"description": "null"
}
response = requests.patch(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.spkey.co/temp-keys/example_string", {
method: "PATCH",
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",
"maxUses": "null",
"accessMode": "public",
"allowedUserIds": [
"example_string"
],
"description": "null"
})
});
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",
"maxUses": "null",
"accessMode": "public",
"allowedUserIds": [
"example_string"
],
"description": "null"
}`)
req, err := http.NewRequest("PATCH", "https://api.spkey.co/temp-keys/example_string", 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/example_string')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Patch.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",
"maxUses": "null",
"accessMode": "public",
"allowedUserIds": [
"example_string"
],
"description": "null"
}'
response = http.request(request)
puts response.body
{
"success": true,
"tempKey": {
"uuid": "example_string",
"url": "example_string",
"validFrom": "example_string",
"validUntil": "example_string",
"description": "null",
"createdBy": "example_string",
"createdAt": "example_string",
"revokedAt": "null",
"accessMode": "public",
"allowedUserIds": [
"example_string"
],
"maxUses": "null",
"usedCount": 3.14,
"doors": [
{
"id": 3.14,
"lockId": "example_string",
"lockUuid": "example_string",
"label": "null",
"accessMethod": "key"
}
]
}
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"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": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred on the server",
"code": 500,
"requestId": "req_1234567890"
}
/temp-keys/{uuid}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.
Collective temporary key UUID
The media type of the request body
null = unlimited
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.
Path Parameters
Collective temporary key UUID
Body
null = unlimited
publicuser-whitelist