great-laptop-90610
10/22/2024, 8:57 AMmetadata_public
field using the admin api?brief-egg-61061
10/22/2024, 8:57 AMbrief-egg-61061
10/22/2024, 8:57 AMmetadata_public
field of an identity, you can use the PUT /admin/identities/{id}
endpoint of the Ory Admin API. This endpoint allows you to update an identity's data, including its metadata. Here is an example of how you might structure your request body: json { "identity": { "metadata_public": { "key1": "value1", "key2": "value2" } } }
Please note that this method replaces the entire metadata object. You can't update only a single value in metadata_public
. For more information, you can refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api#operation/updateIdentity) and the [Ory Kratos Identity Metadata & Traits Guide](https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata).great-laptop-90610
10/22/2024, 9:10 AMbrief-egg-61061
10/22/2024, 9:10 AMbrief-egg-61061
10/22/2024, 9:11 AMmetadata_public
field of an identity using the Go client, you would use the UpdateIdentity
function provided by the Ory Client Go SDK. However, the exact method to update the metadata_public
field is not explicitly mentioned in the provided knowledge sources. Here is a general example of how you might use the UpdateIdentity
function: go package main import ( "context" "fmt" "os" "<http://github.com/ory/client-go/client|github.com/ory/client-go/client>" "<http://github.com/ory/client-go/models|github.com/ory/client-go/models>" ) func main() { cfg := client.NewConfiguration() cfg.Servers = client.ServerConfigurations{ {URL: fmt.Sprintf("<https://%s.projects.oryapis.com>", os.Getenv("ORY_PROJECT_SLUG"))}, } oryClient := client.NewAPIClient(cfg) authed := context.WithValue(context.Background(), client.ContextAccessToken, os.Getenv("ORY_API_KEY")) identity, _, err := oryClient.IdentityApi.GetIdentity(authed, "identity-id").Execute() if err != nil { panic(err) } identity.MetadataPublic = models.IdentityMetadataPublic(map[string]interface{}{ "key1": "value1", "key2": "value2", }) updatedIdentity, _, err := oryClient.IdentityApi.UpdateIdentity(authed, "identity-id").Identity(identity).Execute() if err != nil { panic(err) } fmt.Printf("Updated identity: %+v\n", updatedIdentity) }
Please replace "identity-id"
with the actual ID of the identity you want to update, and replace "key1"
and "key2"
with the actual keys you want to update in the metadata_public
field. Please note that this is a general example and might need adjustments based on your specific use case. For more information, you can refer to the [Ory Client Go SDK Documentation](https://www.ory.sh/docs/kratos/sdk/go).