Error Handling

Handle Embed SDK errors by passing an onError callback to SevenEmbed.render(). The SDK reports both widget-level and SDK-level errors through the same callback. Use the error code to decide whether to retry, request a new token, or correct your configuration.

Adding an error callback

SevenEmbed.render({
  target: '#7shifts-dashboard',
  token: 'ACCESS_TOKEN_FROM_YOUR_BACKEND',
  companyGuid: 'YOUR_COMPANY_GUID',
  components: ['salesLabor'],
  onError: function (error) {
    if (error.code === 'TOKEN_EXPIRED') {
      // Request a new access token from your backend, then re-render the SDK.
      console.error('The access token expired. Request a new token.');
      return;
    }
    console.error('Embed SDK error:', error);
  }
});

Error object

Every error passed to onError has the following shape:

{
  "widget": "salesLabor",
  "status": 401,
  "message": "The resource owner or authorization server denied the request.",
  "code": "TOKEN_EXPIRED"
}
FieldTypeDescription
widgetstringWidget that triggered the error, or global for SDK-level errors.
statusintegerHTTP status code. Network errors use 0.
messagestringHuman-readable error description.
codestringMachine-readable error code. Use this to drive error handling logic.

Error codes

CodeHTTP statusMeaningRecommended action
TOKEN_EXPIRED401Access token is invalid or expired.Generate a new token from your backend and re-initialize the SDK.
FORBIDDEN403Token lacks required scopes.Verify the scopes requested during OAuth.
NOT_FOUND404Requested resource was not found.Verify companyGuid and locationId.
SERVER_ERROR5xx7shifts returned a server error.Retry after a delay.
NETWORK_ERROR0The browser could not reach the API.Check connectivity and retry.
CONFIG_ERRORSDK configuration is invalid.Check required fields: target, token, and companyGuid.