go
rr, err := client.Bundle.Write(context.Background(), &v1.BundleWriteRequest{
TenantId: "t1",
Bundles: []*v1.DataBundle{
{
Name: "organization_created",
Arguments: []string{
"creatorID",
"organizationID",
},
Operations: []*v1.Operation{
{
RelationshipsWrite: []string{
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}",
},
AttributesWrite: []string{
"organization:{{.organizationID}}$public|boolean:false",
},
},
},
},
},
})client.bundle.write({
tenantId: "t1",
bundles: [
{
name: "organization_created",
arguments: [
"creatorID",
"organizationID",
],
operations: [
{
relationships_write: [
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}",
],
attributes_write: [
"organization:{{.organizationID}}$public|boolean:false",
]
}
]
}
]
}).then((response) => {
// handle response
})curl --location --request POST 'localhost:3476/v1/tenants/{tenant_id}/bundle/write' \
--header 'Content-Type: application/json' \
--data-raw '{
"bundles": [
{
"name": "organization_created",
"arguments": [
"creatorID",
"organizationID"
],
"operations": [
{
"relationships_write": [
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}"
],
"attributes_write": [
"organization:{{.organizationID}}$public|boolean:false"
]
}
]
}
]
}'{
"names": [
"<string>"
]
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Bundle Service
Write Bundle
POST
/
v1
/
tenants
/
{tenant_id}
/
bundle
/
write
go
rr, err := client.Bundle.Write(context.Background(), &v1.BundleWriteRequest{
TenantId: "t1",
Bundles: []*v1.DataBundle{
{
Name: "organization_created",
Arguments: []string{
"creatorID",
"organizationID",
},
Operations: []*v1.Operation{
{
RelationshipsWrite: []string{
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}",
},
AttributesWrite: []string{
"organization:{{.organizationID}}$public|boolean:false",
},
},
},
},
},
})client.bundle.write({
tenantId: "t1",
bundles: [
{
name: "organization_created",
arguments: [
"creatorID",
"organizationID",
],
operations: [
{
relationships_write: [
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}",
],
attributes_write: [
"organization:{{.organizationID}}$public|boolean:false",
]
}
]
}
]
}).then((response) => {
// handle response
})curl --location --request POST 'localhost:3476/v1/tenants/{tenant_id}/bundle/write' \
--header 'Content-Type: application/json' \
--data-raw '{
"bundles": [
{
"name": "organization_created",
"arguments": [
"creatorID",
"organizationID"
],
"operations": [
{
"relationships_write": [
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}"
],
"attributes_write": [
"organization:{{.organizationID}}$public|boolean:false"
]
}
]
}
]
}'{
"names": [
"<string>"
]
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}What is Data Bundles?
Ensuring that authorization data remains in sync with the business model is an important practice when using Permify. Prior to Data Bundles, it was the responsibility of the services (such as WriteData API) to structure how relations are created and deleted when actions occur on resources. With the Data Bundles, you be able to bundle and model the creation and deletion of relations and attributes when specific actions occur on resources in your applications. We believe this functionality will streamline managing authorization data as well as managing this in a central place increases visibility around certain actions/triggers that end up with data creation.How Bundles Work
Let’s examine how Bundles operate with a basic example. Let’s say you want to model how data will be created when an organization is created in your application. For this purpose, you can utilize the WriteBundle API endpoint. This API enables users to define or update data bundles, each distinguished by a unique name. Here’s an example body for WriteBundle in this scenario:"bundles": [
{
"name": "organization_created"
"arguments": [
"creatorID",
"organizationID"
],
"operations": [
{
"relationships_write": [
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}",
],
"attributes_write": [
"organization:{{.organizationID}}$public|boolean:false",
],
},
],
},
],
- organization:789#admin@user:564
- organization:789#manager@user:564
- organization:789$public|boolean:false
POST /bundle
BODY
{
"name": "project_created",
"arguments": {
"creatorID": "564",
"organizationID": "789",
}
}
- organization:789#admin@user:564
- organization:789#manager@user:564
- organization:789$public|boolean:false
Endpoints
Write Bundles Request
The “Write Bundle” API is designed for handling data in a multi-tenant application environment. Its primary function is to write and delete data according to predefined structures. This API allows users to define or update data bundles, each distinguished by a unique name.Path Parameters
Body
application/json