This document describes how to use the [Apigee UI](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-use-apigee.md.txt#use-ui),
[Apigee API](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-use-apigee.md.txt#use-api), and
[MessageLogging and PublishMessage policies](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-use-apigee.md.txt#use-policies) with data residency.


For more information about data residency in Apigee, see
[Introduction to data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt).

## Use the Apigee UI with data residency


To access the Apigee UI with data residency, access one of the following consoles
based on your data residency requirements:

- Data residency (at rest only): [Google Cloud console](https://Google Cloud console)
- Advanced data residency: [Jurisdictional console](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt#jurisdictional-console)


The jurisdictional console alters the UI interactions with services as follows:

- You'll only be able to select resource locations that are consistent with your selected control plane location.
- When creating endpoint attachments, you'll only be able to select service attachments consistent with the [Resource Location](https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations) policy of your organization. This prevents access by a private target that isn't in a permitted location.

## Use the Apigee API with data residency


To access the Apigee API with data residency, use the following
regional endpoints described in [Use regional
endpoints for data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts#drz-regional-endpoint).

When using the Apigee API, you will receive a `Permission Denied` error if
you use a [region](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt#drz-regions) that
is prohibited by the control package.

## Use the MessageLogging and PublishMessage policies with data residency

The following sections describe how to update the policy definitions for the
[MessageLogging](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-use-apigee.md.txt#use-message-logging) and [PublishMessage](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-use-apigee.md.txt#use-pubsub)
policies to support data residency.

### Use the MessageLogging policy with data residency

When using the MessageLogging policy, to support data residency
update the policy definition to add the `<Endpoint>` element to the
`<CloudLogging>` element
and set it to the regional endpoint to use for message logging, as follows:

`logging.CONTROL_PLANE_LOCATION.rep.googleapis.com:443`.

> [!IMPORTANT]
> **Important:** When using VPC Service Controls with data residency, you must use the following regional endpoint: `CONTROL_PLANE_LOCATION-logging.googleapis.com`.

<var translate="no">CONTROL_PLANE_LOCATION</var> is the physical location, specified during provisioning,
where Apigee [control plane data](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt#drz-regions) will be stored.

If you don't add the `<Endpoint>` element, the policy defaults to the global endpoint.

For example, the following policy definition uses the regional endpoint for message logging in
the `us` region:

```
<MessageLogging name="LogToCloudLogging">
    <CloudLogging>
        <LogName>projects/{organization.name}/logs/{log.id}</LogName>
        <Message contentType="application/json">{"{message.queryparam.key}": "{message.queryparam.value}"}</Message>
        <Labels>
            <Label>
                <Key>key1</Key>
                <Value>value1</Value>
            </Label>
            <Label>
                <Key>key2</Key>
                <Value>value2</Value>
            </Label>
        </Labels>
        <ResourceType>api</ResourceType>
        <Endpoint>logging.us.rep.googleapis.com:443</Endpoint>
    </CloudLogging>
</MessageLogging>
```

For more information,
see [MessageLogging policy](https://docs.cloud.google.com/apigee/docs/api-platform/reference/policies/message-logging-policy.md.txt).

### Use the PublishMessage policy with data residency

To support data residency, when using the PublishMessage policy, you must
update the policy definition to add the `<Endpoint>` element to the
`<CloudPubSub>` element
and set it to the regional endpoint to use for Pub/Sub messaging, as follows:

`pubsub.CONTROL_PLANE_LOCATION.rep.googleapis.com:443`.

> [!IMPORTANT]
> **Important:** When using VPC Service Controls with data residency, you must set the `<Endpoint>` element to the following regional endpoint:
>
> `CONTROL_PLANE_LOCATION-pubsub.googleapis.com`

<var translate="no">CONTROL_PLANE_LOCATION</var> is the physical location, specified during provisioning,
where Apigee [control plane data](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt#drz-regions) will be stored.

If you don't add the `<Endpoint>` element, the policy defaults to the global endpoint.

For example, the following policy definition uses the regional endpoint for Pub/Sub
messaging in the `us` region:

```
<PublishMessage async="false" continueOnError="false" enabled="true" name="Publish to Pub/Sub">
    <DisplayName>Publish to Pub/Sub</DisplayName>
    <Description>Publish to Pub/Sub</Description>
    <CloudPubSub>
        <Topic>projects/{organization.name}/topics/{topic.name}</Topic>
        <Endpoint>pubsub.us.rep.googleapis.com:443</Endpoint>
    </CloudPubSub>
</PublishMessage>
```

<br />

For more information,
see [PublishMessage policy](https://docs.cloud.google.com/apigee/docs/api-platform/reference/policies/publish-message-policy.md.txt).