# RESTful APIs call

A BundleB2B auth token is required for all BundleB2B RESTful API calls. To generate a BundleB2B auth token, you will need to get a BigCommerce JWT token first.

Note: please contact BundleB2B team for the "app_client_id"

  1. get BigCommerce JWT token

    fetch("https://STORE_DOMAIN_NAME/customer/current.jwt?app_client_id=YOUR_APP_CLIENT_ID")
      .then(response => response.text())
      .then(jwtToken => console.log(jwtToken)) // the BC JWT token
      .catch(error => console.log('error', error));
    
  2. get BundleB2B token

    fetch(`${BUNDLEB2B_API_BASE_URL}/api/v2/login`, {
      method: 'POST',
      body: JSON.stringify({
        bcToken: jwtToken,
       }),
    })
     .then(response => response.text())
     .then(b3Token => console.log(b3Token)) // the BundleB2B auth token
     .catch(error => console.log('error', error));
    
  3. call BundleB2B API

    fetch(`${BUNDLEB2B_API_BASE_URL}API_END_POINT`, {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        authToken: b3Token,
      },
    })
     .then(response => response.text())
     .then(b3result => console.log(b3result))
     .catch(error => console.log('error', error));