v4

latestOpenAPI 3.1.02026-08-02261331761.5 KB
Resource Instances

Create Resource Instance

Creates a new instance inside the Permit.io system.

If the instance is already created: will return 200 instead of 201, and will return the existing instance object in the response body.

post/v2/facts/{proj_id}/{env_id}/resource_instances

Path parameters

proj_idstring required

Either the unique id of the project, or the URL-friendly key of the project (i.e: the "slug").

Either the unique id of the project, or the URL-friendly key of the project (i.e: the "slug").

env_idstring required

Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the "slug").

Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the "slug").

Request body

keystring required

A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the permit.check() API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly.

tenantstring required

the key of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps.

resourcestring required

the key of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be document.

attributesobject

Arbitrary resource attributes that will be used to enforce attribute-based access control policies.

Example request

{
  "key": "react",
  "resource": "repository",
  "tenant": "default",
  "attributes": {
    "private": "false",
    "owner": "facebook"
  }
}

Response

Successful Response

keystring required

A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the permit.check() API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly.

tenantstring required

the key of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps.

resourcestring required

the key of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be document.

idstring uuid required

Unique id of the resource instance

organization_idstring uuid required

Unique id of the organization that the resource instance belongs to.

project_idstring uuid required

Unique id of the project that the resource instance belongs to.

environment_idstring uuid required

Unique id of the environment that the resource instance belongs to.

created_atstring date-time required

Date and time when the resource instance was created (ISO_8601 format).

updated_atstring date-time required

Date and time when the resource instance was last updated/modified (ISO_8601 format).

resource_idstring uuid required

the id of the resource (type) of this resource instance.

tenant_idstring uuid required

the id of the tenant of this resource instance.

attributesobject

Arbitrary resource attributes that will be used to enforce attribute-based access control policies.

Example response

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
  "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4",
  "resource_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c5",
  "tenant_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c3",
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z",
  "key": "react",
  "resource": "repository",
  "tenant": "default",
  "attributes": {
    "private": "false",
    "owner": "facebook"
  }
}