# How to use the Coda API using JS?

**URL:** <https://connect.superhuman.com/t/how-to-use-the-coda-api-using-js/18779>\
**Category:** Ask the Community\
**Created:** [October 6, 2020, 9:36pm UTC](https://connect.superhuman.com/t/how-to-use-the-coda-api-using-js/18779 "2020-10-06T21:36:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Pauwels](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_pauwels/32/14107_2.png) [@Max\_Pauwels](https://connect.superhuman.com/u/Max_Pauwels)\
**Post date:** [October 6, 2020, 9:36pm UTC](https://connect.superhuman.com/t/how-to-use-the-coda-api-using-js/18779/1 "2020-10-06T21:36:37Z")

</div>

Hi guys!

Is anyone familiar with using the Coda API using Javascript?

I am trying to make a simple call, using a test token, but it keeps returning 401 “Unauthorized” errors.

```
$(document).ready(function() {
    $.ajax({
      url: "https://coda.io/apis/v1/docs",
      type: "GET",
      headers: {"Authorization": 'TOKEN'},
      success: function(result) {
        console.log(result);
      },
      error: function(error) {
        console.log(error);
      }
    });
  });

```

I am pretty sure it’s a fairly basic formatting issue, however, the docs don’t demonstrate JS calls.

Is anyone familiar with doing this in JS?

---

<div class="post-metadata">

**Author:** ![Abhishek\_Amit](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/abhishek_amit/32/15666_2.png) [@Abhishek\_Amit](https://connect.superhuman.com/u/Abhishek_Amit)\
**Post date:** [October 7, 2020, 2:54am UTC](https://connect.superhuman.com/t/how-to-use-the-coda-api-using-js/18779/2 "2020-10-07T02:54:13Z")

</div>

Try changing the headers to:

```auto
headers: {"Authorization": 'Bearer TOKEN'},

```

The reference on the Authorization header is here: [https://coda.io/developers/apis/v1#section/Authentication/Bearer](https://coda.io/developers/apis/v1#section/Authentication/Bearer)

---

<div class="post-metadata">

**Author:** ![Max\_Pauwels](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_pauwels/32/14107_2.png) [@Max\_Pauwels](https://connect.superhuman.com/u/Max_Pauwels)\
**Post date:** [October 7, 2020, 1:35pm UTC](https://connect.superhuman.com/t/how-to-use-the-coda-api-using-js/18779/3 "2020-10-07T13:35:57Z")

</div>

That worked! Thanks!
