Delete a resource with the Node.js SDK
permit.api.resources.delete() deletes a resource type, identified by key or ID, from the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who change the policy schema from code.
Prerequisites
- A
permitclient created with an API key for the environment. See Create a Permit client.
Method signature
| Method | Signature | Status |
|---|---|---|
permit.api.resources.delete | delete(resourceKey: string): Promise<void> | Recommended |
permit.api.deleteResource | deleteResource(resourceId: string): Promise<AxiosResponse<void>> | Deprecated alias |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
resourceKey | string | Yes | Key or ID of the resource to delete. |
Example
await permit.api.resources.delete(resourceKey);
Return value
permit.api.resources.delete() resolves to undefined when the resource is deleted. The deprecated permit.api.deleteResource() resolves to the Axios response of the delete request.
If the resource doesn't exist or the Permit API returns another error status code, permit.api.resources.delete() throws a PermitApiError. The deprecated permit.api.deleteResource() rethrows the underlying Axios error.