Deleting Access Codes

Learn how to delete your access codes, and ensure that the code is successfully removed from the device.

1. Delete the access code using the API

To delete an access code, specify the desired access_code_id in the Delete Access Code request.

Request:

access_code_id="daf89de3-ad3a-49aa-93bd-25f27d58f699"

pprint(seam.access_codes.delete(access_code_id))

Response:

ActionAttempt(action_attempt_id='364e747f-9631-4eb1-bc9e-24cd1f11cf5f',
              action_type='DELETE_ACCESS_CODE',
              status='success',
              result={},
              error=None)

Once the access code has been deleted, a request to get the access code returns a 404 error.

Request:

access_code_id="daf89de3-ad3a-49aa-93bd-25f27d58f699"

try:
    seam.access_codes.get(access_code_id)
except Exception as e:
    print(e)

Response:

SeamAPIException: status=404, request_id=4b1d2f1b-3988-4949-9279-fddef25dc9ae, metadata={'type': 'access_code_not_found', 'message': 'Could not find an access_code with device_id or access_code_id', 'data': {'access_code_id': 'daf89de3-ad3a-49aa-93bd-25f27d58f699'}, 'request_id': '4b1d2f1b-3988-4949-9279-fddef25dc9ae'}

2. Verify that the access code has been removed

There are two methods to verify that an access code has been removed:

Polling method

Utilize the action_attempt_id provided in the response from the deletion endpoint to call the Get Action Attempt endpoint. Typically, you'd poll this endpoint until the status reads success.

If the action attempt's status lingers as pending, or if the access code object reveals any warnings or errors properties, see our "Troubleshooting Access Code Issues" guide for help.

Webhook method

Here, you'll need to keep an eye on incoming webhook events. Specifically, watch for the access_code.deleted and access_code.removed_from_device events. These signify successful access code deletion and its removal from the device, respectively. It's worth noting that if you delete an access code that was never programmed onto a device, the access_code.removed_from_device event won't be triggered.

If, however, you encounter access_code.failed_to_remove_from_device or access_code.delay_in_removing_from_device events, it's imperative to consult the "Troubleshooting access code issues" guide.

Last updated

Logo

© Seam Labs, Inc. All rights reserved.