# Set up an API DELETE request - Xano

The **Data Collections** allows you to create API requests to any database or tool with an available REST API.

In this tutorial, we're guiding you on how to create a **DELETE request** to delete data in an external data source from your app. We are going to use an already existing data collection.

If you don't have a Data collection yet, go to [**Data Collection & Binding: Complete Collection**](https://docs.bravostudio.app/connect-api/data-library-and-binding-complete-collection)**.**

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FVr7nb3C6PkTKitMXyiom%2FScreen-Recording-2024-03-18-at-16.08.55.gif?alt=media&#x26;token=fe11d72d-26d7-4380-8684-d8eb78481306" alt=""><figcaption></figcaption></figure>

:point\_right: **Figma file Sample**

Here is the [Figma file](https://www.figma.com/file/wcw77bpYd48s83G1KEFGap/Bravo-samples%3A-Form-Scores?type=design\&node-id=0-1\&mode=design\&t=FpbVWedz7lh9feXH-0) used in the example.

:point\_right: **Database Sample**

We're using this Xano table in this example.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2F4hrrA89lo06mfDvuGiez%2FScreenshot%202024-07-18%20at%2012.27.50.png?alt=media&#x26;token=343f8729-f693-4e05-a9f9-c76495724980" alt=""><figcaption><p>Scores table in Xano</p></figcaption></figure>

:label: **Remote action tag**

Ensure that the `delete` element in your Figma file includes the [remote action](https://docs.bravostudio.app/data-binding/data-binding-types/data-binding-add-remote-actions-to-your-ui) tag.

```
[action:remote]
```

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FnsAFCDtI9S9PjSvm8hF3%2FSet%20up%20an%20API%20DELETE%20request2.jpg?alt=media&#x26;token=b2614e07-663d-4b64-80fa-cf5be258cf95" alt=""><figcaption></figcaption></figure>

### Obtaining the API Request from Xano

1. Within an API group, click on **Add API Endpoint**.
2. Select **CRUD database operations**.
3. Choose the desired table and the **DELETE** operation.
4. Finally, click on the **Copy Endpoint URL**.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2Fbz9zHd8tbtZvikVK3rhm%2FScreen%20Recording%202024-07-18%20at%2012.30.44.gif?alt=media&#x26;token=a6dba6d9-71ce-49f5-8e49-37fd191c2579" alt=""><figcaption><p>Creating DELETE API request in Xano</p></figcaption></figure>

## How to set up a DELETE request in Bravo

1. To create a new request, click the blue "**+**" button.
2. Add a name for the request such as "Delete Scores record"
3. Choose the DELETE method from the request options.
4. Paste the URL that you have copied from Xano's API.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FZqyEsapscWbtNEAFBxyl%2FScreenshot%202024-07-18%20at%2012.43.44.png?alt=media&#x26;token=01bf9dcd-fb6d-49cb-9347-7c7a7bf72625" alt=""><figcaption></figcaption></figure>

5. The URL provided contains the <mark style="color:red;">`{scores_id}`</mark> at the end. Replace this with the [variable](https://docs.bravostudio.app/connect-api/request-url-variables) name <mark style="color:red;">`${scores_id}`</mark>. This change makes it possible to delete any record the user selects by dynamically changing the <mark style="color:red;">`${scores_id}`</mark> variable.
6. To test, go to the **Input Variables & Test Values** tab, add the variable named <mark style="color:red;">`scores_id`</mark>, and set the test value to <mark style="color:red;">`5`</mark>, which corresponds to the 5th item in the table.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FRrhx45f8VQDNpJKmcfWY%2FScreenshot%202024-07-18%20at%2012.47.53.png?alt=media&#x26;token=e678242f-a3d7-4f2c-9bd8-1d8d20cb72ed" alt=""><figcaption></figcaption></figure>

7. Last but not least, do not forget to authenticate the request. Add  the variable name <mark style="color:red;">`_authorization`</mark> and the token as test value in Input Variables & Test Values. Generally, its the same token used in the other requests if you already have them set up.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FQWHusZhqulpkVaWuyasz%2FScreenshot%202024-07-18%20at%2012.52.46.png?alt=media&#x26;token=f802075b-82b3-4056-97e3-f9e7486dfba8" alt=""><figcaption></figcaption></figure>

8. Execute the request by clicking on the **Send** button. \
   \
   In the Received data tab, you'll get a response as "<mark style="color:green;">`Request was successful but no data was sent back in the response, this behaviour is set by the backend you are using. For more info regarding this request go to Debug tab`</mark>"

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FKCjQK2KYZmYjhmy4eqO4%2FScreenshot%202024-07-18%20at%2013.00.27.png?alt=media&#x26;token=aad1b8ba-f842-440b-a9ce-047f0b59422a" alt=""><figcaption><p>Request successful</p></figcaption></figure>

To verify whether an ID has been deleted, please check the Debug tool or Xano.&#x20;

Under the HTTP response, receiving a <mark style="color:red;">`null`</mark> response indicates that item 5 isn't found in the database, confirming it has been deleted successfully.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2F8vnvDxGdgjkNzWFThf5I%2FScreenshot%202024-07-18%20at%2012.48.41.png?alt=media&#x26;token=ad4443f3-6f69-4342-8175-078f6ba41d01" alt=""><figcaption><p>HTTP response 200 - OK</p></figcaption></figure>

To verify in Xano, refresh the scores table and confirm that item 5 has been deleted.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FrZmSjsjyW0OmVe4aX4C4%2FScreenshot%202024-07-18%20at%2012.59.00.png?alt=media&#x26;token=959a5652-a3c5-443d-b9fd-565df34e355a" alt=""><figcaption><p>Updated data in Xano. Item 5 has been deleted.</p></figcaption></figure>

### How to bind the API to the design

1. Once the API request is configured, navigate to the app's binding section.
2. On the left-hand side, under Elements, select the delete element marked by a lightning icon, where you previously inserted the <mark style="color:red;">`[action:remote]`</mark> tag.
3. After selecting the delete element, navigate to the right-hand side and locate the "Remote action" section. Here, choose the API Delete request. You can also set your preferred actions for both "On success" and "On error" scenarios.
4. That's it! Proceed with testing using Bravo Vision.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FkWD8S6p1vOqVNtIXxE9u%2FScreenshot%202024-07-18%20at%2013.11.17.png?alt=media&#x26;token=52cb3b84-67ec-42d0-ba70-6fa65a64885e" alt=""><figcaption></figcaption></figure>

Now, you are ready to go!!&#x20;

Your feedback is valuable to us. If you have any suggestions or questions, please don't hesitate to reach out to us in the [community](https://community.bravostudio.app/home).
