Delete Resource

Delete data from the database using the REST API.


Deleting an entry of an existing object in your database can be easily accomplished by hitting a REST endpoint that includes your table name, and a unique identifier to that resource. Sending a network request to the route will then construct a SQL query that sanitizes and deletes the data from the designated table, at the row with a matching primary key as sent in via the URL.

Request Structure

Every request is simple and standardized in how you interact with a table resource in your database. Follow the below rules and see the example at the bottom for how to apply it to your use case.

Authorization Headers

Every request sent to a StarbaseDB instance must pass in an Authorization Bearer token with a token value matching the value defined in your wrangler.toml file where the variable name is AUTHORIZATION_TOKEN. For any request that does not have a matching token value, the request will automatically be denied and cannot pass into the storage layer of your database.

An example cURL including the Bearer token can be seen below.

curl --location 'https://starbasedb.YOUR-IDENTIFIER.workers.dev/rest/your_table_name' \
--header 'Authorization: Bearer ABC123' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'Content-type=application/json'

Route

Updating some fields in an existing database object happens via an HTTP DELETE request with a route of /rest/{YOUR_TABLE_NAME}/{PK_VALUE}.

  • YOUR_TABLE_NAME can be replaced with any table name in your database

  • PK_VALUE should match the unique primary key column identifier for this row. If your primary key column was id and the entry you wanted to update had a value of 5 in that field, you would pass 5 in the URL.

Example

Use the below example to get started.

curl --location --request DELETE 'https://starbasedb.YOUR-IDENTIFIER.workers.dev/rest/users/5' \
--header 'Authorization: Bearer ABC123'
Updated on