Skip to main content

Obligations

An obligation is a PDP-to-PEP directive that accompanies an access decision: "permit, provided these controls are enforced." Obligations are scoped to a namespace and can carry multiple values and triggers. See Obligations for the policy concept.

Setup

All examples on this page assume you have created a platform client. See Authentication for full details including DPoP key binding.

import (
"context"
"log"

"github.com/opentdf/platform/sdk"
)

client, err := sdk.New("http://localhost:8080",
sdk.WithClientCredentials("opentdf", "secret", nil),
)
if err != nil {
log.Fatal(err)
}

// All Go snippets below use `client` and `context.Background()`.
// The Obligations service is accessed via client.Obligations.

Obligation Definitions

List Obligations

Signature

client.Obligations.ListObligations(ctx, &obligations.ListObligationsRequest{...})

Parameters

ParameterTypeRequiredDescription
namespaceIdstring (UUID)NoFilter to obligations in this namespace.
namespaceFqnstring (URI)NoFilter by namespace FQN. Alternative to namespaceId.

Without a filter, returns all obligations across all namespaces.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.ListObligations(context.Background(),
&obligations.ListObligationsRequest{},
)
if err != nil {
log.Fatal(err)
}
for _, obl := range resp.GetObligations() {
log.Printf("Obligation: %s FQN: %s\n", obl.GetName(), obl.GetFqn())
}

To filter by namespace:

resp, err := client.Obligations.ListObligations(context.Background(),
&obligations.ListObligationsRequest{
NamespaceFqn: "https://example.com",
},
)

Returns

A list of Obligation objects.

Get an Obligation

Signature

client.Obligations.GetObligation(ctx, &obligations.GetObligationRequest{...})

Parameters

Provide one of the following (exactly one is required):

ParameterTypeDescription
idstring (UUID)The obligation UUID.
fqnstringThe obligation FQN (e.g., https://example.com/obl/drm).

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.GetObligation(context.Background(),
&obligations.GetObligationRequest{
Fqn: "https://example.com/obl/drm",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Obligation ID: %s\n", resp.GetObligation().GetId())

Returns

A single Obligation object.

Get Obligations by FQNs

Batch-fetch multiple obligations by FQN in a single request.

Signature

client.Obligations.GetObligationsByFQNs(ctx, &obligations.GetObligationsByFQNsRequest{...})

Parameters

ParameterTypeRequiredDescription
fqns[]stringYesObligation FQNs to look up.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.GetObligationsByFQNs(context.Background(),
&obligations.GetObligationsByFQNsRequest{
Fqns: []string{
"https://example.com/obl/drm",
"https://example.com/obl/audit",
},
},
)
if err != nil {
log.Fatal(err)
}
for fqn, obl := range resp.GetFqnObligationMap() {
log.Printf("%s → %s\n", fqn, obl.GetId())
}

Returns

A map of FQN to Obligation object.

Create an Obligation

Signature

client.Obligations.CreateObligation(ctx, &obligations.CreateObligationRequest{...})

Parameters

ParameterTypeRequiredDescription
namespaceIdstring (UUID)Yes*The parent namespace. Required unless namespaceFqn is provided.
namespaceFqnstring (URI)Yes*The parent namespace FQN. Alternative to namespaceId.
namestringYesObligation name (e.g., drm, audit).
values[]stringNoInitial values to create with the obligation. Can also be added later via Create Obligation Value.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.CreateObligation(context.Background(),
&obligations.CreateObligationRequest{
NamespaceFqn: "https://example.com",
Name: "drm",
Values: []string{"watermarking", "no-download"},
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Created obligation: %s FQN: %s\n",
resp.GetObligation().GetId(), resp.GetObligation().GetFqn())

Returns

The created Obligation object. The resulting FQN follows the convention <namespace>/obl/<name> (e.g., https://example.com/obl/drm).

Update an Obligation

Signature

client.Obligations.UpdateObligation(ctx, &obligations.UpdateObligationRequest{...})

Parameters

ParameterTypeRequiredDescription
idstring (UUID)YesThe obligation ID to update.
namestringNoNew name. Only set fields are updated.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.UpdateObligation(context.Background(),
&obligations.UpdateObligationRequest{
Id: "3f4a7c12-...",
Name: "digital-rights",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Updated obligation FQN: %s\n", resp.GetObligation().GetFqn())

Returns

The updated Obligation object.

Delete an Obligation

Signature

client.Obligations.DeleteObligation(ctx, &obligations.DeleteObligationRequest{...})

Parameters

Provide one of the following (exactly one is required):

ParameterTypeDescription
idstring (UUID)The obligation UUID.
fqnstringThe obligation FQN.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.DeleteObligation(context.Background(),
&obligations.DeleteObligationRequest{
Fqn: "https://example.com/obl/drm",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Deleted obligation: %s\n", resp.GetObligation().GetId())

Returns

The deleted Obligation object.

Obligation Object

FieldTypeDescription
idstring (UUID)Unique identifier, generated by the platform.
namestringThe obligation name (e.g., drm, audit).
fqnstringFully qualified name, e.g., https://example.com/obl/drm.
values[]ObligationValueThe values defined under this obligation.
namespaceNamespaceThe parent namespace.
metadataMetadataOptional labels.

Obligation Values

Each obligation can carry one or more values. Value FQNs follow the convention <namespace>/obl/<obligation_name>/value/<value> (e.g., https://example.com/obl/drm/value/watermarking).

Get an Obligation Value

Signature

client.Obligations.GetObligationValue(ctx, &obligations.GetObligationValueRequest{...})

Parameters

Provide one of the following (exactly one is required):

ParameterTypeDescription
idstring (UUID)The value UUID.
fqnstringThe value FQN (e.g., https://example.com/obl/drm/value/watermarking).

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.GetObligationValue(context.Background(),
&obligations.GetObligationValueRequest{
Fqn: "https://example.com/obl/drm/value/watermarking",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Value ID: %s\n", resp.GetValue().GetId())

Returns

A single Obligation Value object.

Get Obligation Values by FQNs

Signature

client.Obligations.GetObligationValuesByFQNs(ctx, &obligations.GetObligationValuesByFQNsRequest{...})

Parameters

ParameterTypeRequiredDescription
fqns[]stringYesObligation value FQNs to look up.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.GetObligationValuesByFQNs(context.Background(),
&obligations.GetObligationValuesByFQNsRequest{
Fqns: []string{
"https://example.com/obl/drm/value/watermarking",
"https://example.com/obl/drm/value/no-download",
},
},
)
if err != nil {
log.Fatal(err)
}
for fqn, val := range resp.GetFqnValueMap() {
log.Printf("%s → %s\n", fqn, val.GetId())
}

Returns

A map of FQN to Obligation Value object.

Create an Obligation Value

Signature

client.Obligations.CreateObligationValue(ctx, &obligations.CreateObligationValueRequest{...})

Parameters

ParameterTypeRequiredDescription
obligationIdstring (UUID)Yes*The parent obligation. Required unless obligationFqn is provided.
obligationFqnstringYes*The parent obligation FQN. Alternative to obligationId.
valuestringYesThe value string (e.g., watermarking, encrypt-at-rest).

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.CreateObligationValue(context.Background(),
&obligations.CreateObligationValueRequest{
ObligationFqn: "https://example.com/obl/drm",
Value: "encrypt-at-rest",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Created value: %s FQN: %s\n",
resp.GetValue().GetId(), resp.GetValue().GetFqn())

Returns

The created Obligation Value object.

Update an Obligation Value

Signature

client.Obligations.UpdateObligationValue(ctx, &obligations.UpdateObligationValueRequest{...})

Parameters

ParameterTypeRequiredDescription
idstring (UUID)YesThe value ID to update.
valuestringNoNew value string.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.UpdateObligationValue(context.Background(),
&obligations.UpdateObligationValueRequest{
Id: "9a1b2c3d-...",
Value: "encrypt-at-rest-v2",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Updated value FQN: %s\n", resp.GetValue().GetFqn())

Returns

The updated Obligation Value object.

Delete an Obligation Value

Signature

client.Obligations.DeleteObligationValue(ctx, &obligations.DeleteObligationValueRequest{...})

Parameters

Provide one of the following (exactly one is required):

ParameterTypeDescription
idstring (UUID)The value UUID.
fqnstringThe value FQN.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.DeleteObligationValue(context.Background(),
&obligations.DeleteObligationValueRequest{
Fqn: "https://example.com/obl/drm/value/watermarking",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Deleted value: %s\n", resp.GetValue().GetId())

Returns

The deleted Obligation Value object.

Obligation Value Object

FieldTypeDescription
idstring (UUID)Unique identifier, generated by the platform.
valuestringThe value string (e.g., watermarking, no-download).
fqnstringFully qualified name, e.g., https://example.com/obl/drm/value/watermarking.
obligationObligationThe parent obligation.
triggers[]ObligationTriggerTriggers associated with this value.
metadataMetadataOptional labels.

Triggers

A trigger links an obligation value to a specific action + attribute value combination. When that action is performed on data carrying that attribute value, the obligation fires.

Add an Obligation Trigger

Signature

client.Obligations.AddObligationTrigger(ctx, &obligations.AddObligationTriggerRequest{...})

Parameters

ParameterTypeRequiredDescription
obligationValueIdFqnIdentifierYesThe obligation value to trigger. Provide id or fqn.
actionIdNameIdentifierYesThe action that fires this trigger. Provide id or name (e.g., read).
attributeValueIdFqnIdentifierYesThe attribute value that must be present on the data. Provide id or fqn.

Example

import (
"github.com/opentdf/platform/protocol/go/common"
"github.com/opentdf/platform/protocol/go/policy/obligations"
)

resp, err := client.Obligations.AddObligationTrigger(context.Background(),
&obligations.AddObligationTriggerRequest{
ObligationValue: &common.IdFqnIdentifier{
Fqn: "https://example.com/obl/drm/value/watermarking",
},
Action: &common.IdNameIdentifier{
Name: "read",
},
AttributeValue: &common.IdFqnIdentifier{
Fqn: "https://example.com/attr/classification/value/secret",
},
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Added trigger: %s\n", resp.GetTrigger().GetId())

Returns

The created Obligation Trigger object.

List Obligation Triggers

Signature

client.Obligations.ListObligationTriggers(ctx, &obligations.ListObligationTriggersRequest{...})

Parameters

ParameterTypeRequiredDescription
namespaceFqnstring (URI)NoFilter to triggers in this namespace.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.ListObligationTriggers(context.Background(),
&obligations.ListObligationTriggersRequest{
NamespaceFqn: "https://example.com",
},
)
if err != nil {
log.Fatal(err)
}
for _, trigger := range resp.GetTriggers() {
log.Printf("Trigger ID: %s\n", trigger.GetId())
}

Returns

A list of Obligation Trigger objects.

Remove an Obligation Trigger

Signature

client.Obligations.RemoveObligationTrigger(ctx, &obligations.RemoveObligationTriggerRequest{...})

Parameters

ParameterTypeRequiredDescription
idstring (UUID)YesThe trigger ID to remove.

Example

import "github.com/opentdf/platform/protocol/go/policy/obligations"

resp, err := client.Obligations.RemoveObligationTrigger(context.Background(),
&obligations.RemoveObligationTriggerRequest{
Id: "7e8f9a0b-...",
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Removed trigger: %s\n", resp.GetTrigger().GetId())

Returns

The removed Obligation Trigger object.

Obligation Trigger Object

FieldTypeDescription
idstring (UUID)Unique identifier, generated by the platform.
obligationValueObligationValueThe obligation value this trigger fires for.
actionActionThe action that activates this trigger (e.g., read).
attributeValueValueThe attribute value that must be present on the data.
metadataMetadataOptional labels.