> ## Documentation Index
> Fetch the complete documentation index at: https://docs.authsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Server SDKs - Error handling

> Learn how to handle errors when using Authsignal's server SDKs.

Authsignal Server SDKs can return errors for a variety of reasons, such as invalid requests or network interruptions, which should be handled accordingly.

<CodeGroup>
  ```ts Node.js theme={null}
  const request = {
    userId: "dc58c6dc-a1fd-4a4f-8e2f-846636dd4833",
  };

  try {
    const response = await authsignal.getUser(request);
  } catch (e) {
    if (e instanceof AuthsignalError) {
      const statusCode = e.statusCode;
      const errorCode = e.errorCode;
      const errorDescription = e.errorDescription;
    }
  }
  ```

  ```csharp C# theme={null}
  var request = new GetUserRequest(
      UserId: "dc58c6dc-a1fd-4a4f-8e2f-846636dd4833"
  );

  try
  {
      var response = await authsignal.GetUser(request);
  }
  catch (AuthsignalException e)
  {
      var statusCode = e.StatusCode;
      var errorCode = e.ErrorCode;
      var errorDescription = e.ErrorDescription;
  }
  ```

  ```java Java theme={null}
  UserRequest request = new GetUserRequest();
  request.userId = "dc58c6dc-a1fd-4a4f-8e2f-846636dd4833";

  try {
      GetUserResponse response = authsignal.getUser(request).get();
  } catch (ExecutionException e) {
      if (e.getCause() instanceof AuthsignalException) {
          AuthsignalException exception = (AuthsignalException) e.getCause();
          int statusCode = exception.getStatusCode();
          String errorCode = exception.getErrorCode();
          String errorDescription = exception.getErrorDescription();
      }
  }
  ```

  ```ruby Ruby theme={null}
  begin
      response = Authsignal.get_user(user_id: "dc58c6dc-a1fd-4a4f-8e2f-846636dd4833")
  rescue Authsignal::ApiError => e
      status_code = e.status_code
      error_code = e.error_code
      error_description = e.error_description
  end
  ```

  ```python Python theme={null}
  try:
      response = authsignal.get_user(user_id="dc58c6dc-a1fd-4a4f-8e2f-846636dd4833")
  except ApiException as e:
      status_code = e.status_code
      error_code = e.error_code
      error_description = e.error_description
  ```

  ```PHP PHP theme={null}
  try {
      $response = Authsignal::getUser([
          'userId' => "dc58c6dc-a1fd-4a4f-8e2f-846636dd4833"
      ]);
  } catch(AuthsignalError $e) {
      $statusCode = $e["statusCode"];
      $errorCode = $e["errorCode"];
      $errorDescription = $e["errorDescription"];
  }
  ```

  ```go Go theme={null}
  request := client.GetUserRequest{
      UserId: "dc58c6dc-a1fd-4a4f-8e2f-846636dd4833",
  }

  response, err := authsignal.GetUser(request)

  if err != nil {
      if apiErr, ok := err.(*client.AuthsignalAPIError); ok {
          statusCode := apiErr.StatusCode
          errorCode := apiErr.ErrorCode
          errorDescription := apiErr.ErrorDescription
      }
      return
  }
  ```
</CodeGroup>

## Error fields

<ResponseField name="statusCode" type="integer">
  The HTTP status code returned by the Authsignal Server API.
</ResponseField>

<ResponseField name="errorCode" type="string">
  A code which identifies a [specific error state](#error-codes).
</ResponseField>

<ResponseField name="errorDescription" type="string">
  A free-text description of the error. This value should only be used for logging or
  troubleshooting purposes.
</ResponseField>

## Error codes

<ResponseField name="invalid_configuration">
  Indicates that the request cannot be handled because the tenant is in an invalid configuration.
</ResponseField>

<ResponseField name="invalid_credential">
  Indicates that the credential (e.g. passkey) referenced by the request is invalid for the given
  user and cannot be authenticated.
</ResponseField>

<ResponseField name="invalid_request">
  Indicates that the request failed due to an invalid parameter or input.
</ResponseField>

<ResponseField name="too_many_requests">
  Indicates that the server cannot respond as requests have been rate-limited due to exceeding a
  threshold.
</ResponseField>

<ResponseField name="unauthorized">
  Indicates that the request is unauthorized due to invalid tenant credentials - for example if the
  Server API secret key is invalid or if the region doesn't match.
</ResponseField>

<ResponseField name="webhook_error">
  Indicates that the request failed due to an error returned by an invoked webhook. The error
  description will include more information about the webhook error.
</ResponseField>
