Create Pull Request
| Date | Scan | Status | Result |
|---|---|---|---|
| 2026-01-14 00:00 | #250 | in_progress |
Clean
|
| 2026-01-13 00:00 | #246 | completed |
Clean
|
| 2026-01-11 00:00 | #240 | completed |
Clean
|
| 2026-01-10 00:00 | #237 | completed |
Clean
|
| 2026-01-09 00:34 | #234 | completed |
Clean
|
| 2026-01-08 00:53 | #231 | completed |
Clean
|
| 2026-01-06 18:15 | #225 | cancelled |
Clean
|
| 2025-08-17 00:01 | #83 | cancelled |
Clean
|
| 2025-07-13 21:37 | #48 | completed |
Clean
|
| 2025-07-09 13:09 | #3 | cancelled |
Clean
|
| 2025-07-08 04:23 | #2 | cancelled |
Biased
|
Your variables should now look something like this:
:::image type="content" source="media/how-to-use-apis/variables-token-control.png" alt-text="Screenshot of the control plane variables, including a token." lightbox="media/how-to-use-apis/variables-token-control.png":::
---
## Add requests
Now that your `.http` file is set up, you can add requests to the Azure Digital Twin APIs.
Start by opening the [Azure Digital Twins REST API reference](/rest/api/azure-digitaltwins/). This documentation contains details of all the operations covered by the APIs. Navigate to the reference page of the request you want to run.
This article uses the [DigitalTwins Update API](/rest/api/digital-twins/dataplane/twins/digital-twins-update) from the data plane as an example.
1. **Add request template**: Copy the HTTP request shown in the reference documentation.
:::image type="content" source="media/how-to-use-apis/copy-request.png" alt-text="Screenshot of the HTTP request in the Digital Twins API documentation." lightbox="media/how-to-use-apis/copy-request.png":::
In Visual Studio, paste the request in a new line below the variables in your `.http` file.
1. **Add parameters**: Look at the **URI Parameters** section of the reference documentation to see which parameter values are needed by the request. You can replace some with the [variables](#add-variables) you created earlier, and fill in other parameter values as appropriate. To reference a variable, put the variable name in double curly braces, like `{{variable}}`. For more information, see [Variables](/aspnet/core/test/http-files#variables).
>[!NOTE]
>For data plane requests, `digitaltwins-hostname` is also a parameter. Replace this parameter value with `{{hostName}}` to use the value of your host name variable.
Here's how this step looks in an example request:
:::image type="content" source="media/how-to-use-apis/add-parameters.png" alt-text="Screenshot of the request with parameters in Visual Studio." lightbox="media/how-to-use-apis/add-parameters.png":::
1. **Add authorization**: To specify authentication with your bearer token variable, add the following line (exactly as written) directly underneath the request.
---
>[!NOTE]
> If you need to access your Azure Digital Twins instance using a service principal or user account that belongs to a different Microsoft Entra tenant from the instance, you need to request a token from the Azure Digital Twins instance's "home" tenant. For more information on this process, see [Write app authentication code](how-to-authenticate-client.md#authenticate-across-tenants).
3. Copy the value of `accessToken` in the result. This value is your **token value** that you paste into Visual Studio to authorize your requests.
:::image type="content" source="media/how-to-use-apis/console-access-token.png" alt-text="Screenshot of the console showing the result of the az account get-access-token command. The accessToken field with a sample value is highlighted." lightbox="media/how-to-use-apis/console-access-token.png":::
>[!TIP]
>This token is valid for at least five minutes and a maximum of 60 minutes. If you run out of time allotted for the current token, you can repeat the steps in this section to get a new one.
### Add token to `.http` file
In your `.http` file in Visual Studio, add another variable that holds the value of your token.
# [Data plane](#tab/data-plane)