# hubdb publish api

**URL:** <https://community.hubspot.com/t/hubdb-publish-api/75611>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [February 21, 2023, 7:31am UTC](https://community.hubspot.com/t/hubdb-publish-api/75611 "2023-02-21T07:31:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuweikuo](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Shuweikuo](https://community.hubspot.com/u/Shuweikuo)\
**Post date:** [February 21, 2023, 7:31am UTC](https://community.hubspot.com/t/hubdb-publish-api/75611/1 "2023-02-21T07:31:39Z")

</div>

I tried to publish the table via api, but either `draft/push-live` nor `draft/publish` work for me.  
Anyone could help me or has any idea ?🙏🙏🙏🙏🙏🙏🙏🙏

```lia-code-sample
const publishTable = async auth => {
 return await axios.post(
 `${HUBDB_API}/${HUBDB_TABLE_ID}/draft/publish`,
 {
 headers: {
 "Accept": "application/json",
 'Content-Type' : 'application/json',
 'Authorization' : `Bearer ${BIAPIKEY}`
 }
 }
 );
}

```

`

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [February 21, 2023, 11:03am UTC](https://community.hubspot.com/t/hubdb-publish-api/75611/2 "2023-02-21T11:03:23Z")

</div>

Hmm two things to check:

1. Hubspot no longer allows the use of API keys, you have to use an access token from a private app. If you don’t have that set up, you just need to set up a private app that has access to the hubdb scope. It will then generate a token for you.

2. Double check that the value of HUBDB\_API is “[https://api.hubapi.com/cms/v3/hubdb/tables/](https://api.hubapi.com/cms/v3/hubdb/tables/)” as the full URL to POST to should be “[https://api.hubapi.com/cms/v3/hubdb/tables/${HUBDB\_TABLE\_ID}/draft/publish](https://api.hubapi.com/cms/v3/hubdb/tables/$%7BHUBDB_TABLE_ID%7D/draft/publish)”

For reference, this works for me:

```lia-code-sample
function updateTable(tableId){
 let url = `https://api.hubapi.com/cms/v3/hubdb/tables/${tableId}/draft/publish`;
 return fetch(url, {
 method: 'POST',
 headers: {
 'Authorization': `Bearer ${token}`,
 'accept': 'application/json',
 'Content-Type': 'application/json'
 }
 })
 .then(response => ({status: response.stats}));
}

Promise.all([
 updateTable([ID1])
 updateTable([ID2])
])
 .then(data => doMoreThings(data))
 .catch(err => console.log(err));

```
