Skip to main content

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

Method signature

MethodSignatureStatus
permit.api.resources.deletedelete(resourceKey: string): Promise<void>Recommended
permit.api.deleteResourcedeleteResource(resourceId: string): Promise<AxiosResponse<void>>Deprecated alias

Parameters

NameTypeRequiredDescription
resourceKeystringYesKey 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.