[Tip of the Week] Delete all Table Records using a Bot

hello,

in this week’s Tip of the Week, I’d like to share how you can delete all Records from a Tulip Table using the Table API.

warning: this deletes all Records from a Table, please use caution

there are three main steps to achieving this: 1. create a Bot in your instance, 2. build a Connector, 3. write the Connector Function.

  1. navigate to https://{{instance_name}}.tulip.co/account-settings/bots (please note you need to be an Account Owner to open this page). once you’ve accessed this page, click Create Bot that can be found at the top right:


    give the Bot a Name and enable the tables:write Scope:

    note: leave the tab open so you can copy/paste the API Key and Secret:

  2. create a new Connector Function and enter the details as follows (replacing the URL with your instance URL):


    open the Headers section and paste the credentials from the Bot you just created. please note that the Username is the API Key and the Password is the Secret:

  3. build a Connector Function with 1 input named tableID, DELETE as the method, and the following endpoint: /api/v3/tables/$tableID/records. as you see below the tableID in the URL will turn gray to confirm its been mapped to the Input:

once you enter a Table ID (found in the URL when you open a Table) in the Input and click Test (top right), you can Delete all the Table Records. and that’s it, you’re now ready to empty your Tables with just the click of a button!! again, please use caution as this deletes all records from your Table.

have people used this already?? if so, share why and when you use it.

1 Like

Hey Gio.

I tried this on my instance but I get this error message.

{

2 items

“errorCode”:

string"NoSuchEndpoint"

“details”:

string"That API endpoint does not exist"

}

Hey @mrios92 -

Can you shoot me a screenshot of your connector function? (Similar to this one)

A few things could be going on here. But we can sort it out!
Pete

Hi Pete.

Hey @mrios92 -

I think the only issue was in the header url. Right now it is ...api/v2/tables/{tableid}/records but to embed the user inputted tableid it needs to be ...api/v2/tables/$tableid$/records.

I made this change in your connector, want to test it out and see if that works the way you’d expect it to?

Pete

As a note, if any of the records are currently loaded in a station, this DELETE request will fail. You can work around that by passing in a query parameter of allowRecordsInUse and set that to true.

Thanks Pete, still getting the same error code as before:

{

2 items

“errorCode”:

string"NoSuchEndpoint"

“details”:

string"That API endpoint does not exist"

}

Hey @mrios92 -

Sorry about the delay on this one. Just duplicated your connector and got it working. There is was a bug introduced very recently around inputs to duplicated functions. Removing the input and re-adding it resolves this issue.

Thanks for all the great info.
Pete

1 Like

Hello,
If this issue was revived elsewhere, please point me in the right direction.
I’m trying to use it myself to empty several tables and on the way to learn a bit about connectors and functions. However, several things have changed I belive:

  1. There aren’t any Bots anymore, now they’re called API Tokens, right?
  2. For the life of me I can’t find the screen where I’m supposed to input the Token’s details into the connector:

    The connector details screen I’ve found has way fewer details (I’ve created an SQL connector):
    image

Thank you for helping!

Hi @AquaMaofian,

it must be a HTTP connector to use APIs.
This will not work with a SQL connector.

Then click on “edit Headers” and you will find the section “Authentication” on top, where you can set a “Basic Auth”.

Also your Host is not gio.tulip.co but your instance root address…

1 Like

Thanks for chiming in Thorsten! I agree with everything he has suggested here :slight_smile:

I’ll just add that yes, bots are now called API tokens.

We have a Tulip University Table API course that will walk you through the process of getting everything set up that you may find helpful as well! https://university.tulip.co/feature-deep-dive-table-api

We also have some resources on our knowledge base if you prefer to read through those - How to Use the Table API