Skip to content

Wildberries API TypeScript SDK / AuthenticationError

Class: AuthenticationError

Defined in: errors/auth-error.ts:25

Authentication error thrown when API key is invalid or lacks permissions.

This error is thrown for:

  • 401 Unauthorized responses (invalid API key)
  • 403 Forbidden responses (insufficient permissions)
  • Client-side API key validation failures

Example

typescript
import { AuthenticationError } from 'daytona-wildberries-typescript-sdk';

try {
  await sdk.general.ping();
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key:', error.getUserMessage());
    // Prompt user to update API key in settings
  }
}

Extends

Constructors

Constructor

ts
new AuthenticationError(
   message: string, 
   statusCode: 401 | 403, 
   response?: unknown, 
   requestId?: string): AuthenticationError;

Defined in: errors/auth-error.ts:34

Creates an authentication error

Parameters

ParameterTypeDefault valueDescription
messagestring'Authentication failed. Please verify your API key is valid and has the required permissions.'Error message (defaults to standard authentication failure message)
statusCode401 | 403401HTTP status code (401 or 403)
response?unknownundefinedAPI response body if available
requestId?stringundefinedCorrelation ID for debugging

Returns

AuthenticationError

Overrides

WBAPIError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
<a id="statuscode"></a> statusCode?readonlynumberHTTP status code if applicableWBAPIError.statusCodeerrors/base-error.ts:25
<a id="response"></a> response?readonlyunknownAPI response body if availableWBAPIError.responseerrors/base-error.ts:30
<a id="requestid"></a> requestId?readonlystringCorrelation ID for debugging and tracing requestsWBAPIError.requestIderrors/base-error.ts:35

Methods

getUserMessage()

ts
getUserMessage(): string;

Defined in: errors/auth-error.ts:49

Returns user-friendly error message with API key troubleshooting guidance

Returns

string

Error message with actionable recovery steps

Overrides

WBAPIError.getUserMessage


toJSON()

ts
toJSON(): {
  name: string;
  message: string;
  statusCode?: number;
  response?: unknown;
  requestId?: string;
};

Defined in: errors/base-error.ts:125

Custom JSON serialization to preserve all error properties.

By default, Error objects don't serialize the message property when using JSON.stringify(). This method ensures all important properties are included in the JSON output.

Returns

ts
{
  name: string;
  message: string;
  statusCode?: number;
  response?: unknown;
  requestId?: string;
}

Object representation of the error for JSON serialization

NameTypeDefined in
namestringerrors/base-error.ts:126
messagestringerrors/base-error.ts:127
statusCode?numbererrors/base-error.ts:128
response?unknownerrors/base-error.ts:129
requestId?stringerrors/base-error.ts:130

Example

typescript
const error = new WBAPIError('Test error', 400, { detail: 'info' }, 'req-123');
const json = JSON.stringify(error);
// { "name": "WBAPIError", "message": "Test error", "statusCode": 400, ... }

Inherited from

WBAPIError.toJSON

Made with ❤️ for the Wildberries developer community