# externalApifyApiError<!-- -->

An `ApifyApiError` is thrown for successful HTTP requests that reach the API, but the API responds with an error response. Typically, those are rate limit errors and internal errors, which are automatically retried, or validation errors, which are thrown immediately, because a correction by the user is needed.

The thrown error is an instance of the subclass matching the HTTP status code of the response: [InvalidRequestError](https://docs.apify.com/sdk/js/reference/class/InvalidRequestError.md) (400), [UnauthorizedError](https://docs.apify.com/sdk/js/reference/class/UnauthorizedError.md) (401), [ForbiddenError](https://docs.apify.com/sdk/js/reference/class/ForbiddenError.md) (403), [NotFoundError](https://docs.apify.com/sdk/js/reference/class/NotFoundError.md) (404), [ConflictError](https://docs.apify.com/sdk/js/reference/class/ConflictError.md) (409), [RateLimitError](https://docs.apify.com/sdk/js/reference/class/RateLimitError.md) (429) or [ServerError](https://docs.apify.com/sdk/js/reference/class/ServerError.md) (5xx). Any other status code is thrown as a plain `ApifyApiError`. Every subclass extends `ApifyApiError`, so `instanceof ApifyApiError` matches all of them. Errors that share a status code are told apart by their `type`.

### Hierarchy

* [ApifyClientError](https://docs.apify.com/sdk/js/reference/class/ApifyClientError.md)

  * *ApifyApiError*

    * [InvalidRequestError](https://docs.apify.com/sdk/js/reference/class/InvalidRequestError.md)
    * [UnauthorizedError](https://docs.apify.com/sdk/js/reference/class/UnauthorizedError.md)
    * [ForbiddenError](https://docs.apify.com/sdk/js/reference/class/ForbiddenError.md)
    * [NotFoundError](https://docs.apify.com/sdk/js/reference/class/NotFoundError.md)
    * [ConflictError](https://docs.apify.com/sdk/js/reference/class/ConflictError.md)
    * [RateLimitError](https://docs.apify.com/sdk/js/reference/class/RateLimitError.md)
    * [ServerError](https://docs.apify.com/sdk/js/reference/class/ServerError.md)

## Index[](#Index)

### Properties

* [attempt](#attempt)
* [cause](#cause)
* [clientMethod](#clientMethod)
* [data](#data)
* [httpMethod](#httpMethod)
* [message](#message)
* [name](#name)
* [originalStack](#originalStack)
* [path](#path)
* [stack](#stack)
* [statusCode](#statusCode)
* [type](#type)
* [stackTraceLimit](#stackTraceLimit)

### Methods

* [captureStackTrace](#captureStackTrace)
* [isError](#isError)
* [prepareStackTrace](#prepareStackTrace)

## Properties<!-- -->[](#Properties)

### [](#attempt)externalattempt

attempt: number

Number of the API call attempt.

### [](#cause)externaloptionalinheritedcause

cause?

<!-- -->

: unknown

Inherited from ApifyClientError.cause

### [](#clientMethod)externalclientMethod

clientMethod: string

The resource client and the method parsed from the stack trace, such as `ActorClient.getResource`. A public method that delegates to a shared helper of its class is reported under the helper. The value is `unknown` when the stack trace cannot be parsed.

### [](#data)externaloptionaldata

data?

<!-- -->

: Record\<string, unknown>

Additional data provided by the API about the error

### [](#httpMethod)externaloptionalhttpMethod

httpMethod?

<!-- -->

: string

HTTP method of the API call.

### [](#message)externalinheritedmessage

message: string

Inherited from ApifyClientError.message

### [](#name)externalname

name: string

Overrides ApifyClientError.name

### [](#originalStack)externaloriginalStack

originalStack: string

Original stack trace of the exception. It is replaced by a more informative stack with API call information.

### [](#path)externaloptionalpath

path?

<!-- -->

: string

Full path of the API endpoint (URL excluding origin).

### [](#stack)externaloptionalinheritedstack

stack?

<!-- -->

: string

Inherited from ApifyClientError.stack

### [](#statusCode)externalstatusCode

statusCode: number

HTTP status code of the error.

### [](#type)externaloptionaltype

type?

<!-- -->

: 3d-secure-auth-failed | access-right-already-exists | action-not-found | actor-already-rented | actor-can-not-be-rented | actor-disabled | actor-is-not-rented | actor-memory-limit-exceeded | actor-name-exists-new-owner | actor-name-not-unique | actor-not-found | actor-not-github-actor | actor-not-public | actor-review-already-exists | actor-run-failed | actor-task-name-not-unique | airtable-webhook-deprecated | already-subscribed-to-paid-actor | apify-plan-required-to-use-paid-actor | apify-signup-not-allowed | auth-method-not-supported | authorization-server-not-found | auto-issue-date-invalid | background-check-required | billing-system-error | black-friday-plan-expired | braintree-error | braintree-not-linked | braintree-operation-timed-out | braintree-unsupported-currency | build-not-found | build-outdated | cannot-add-apify-events-to-ppe-actor | cannot-add-multiple-pricing-infos | cannot-add-pricing-info-that-alters-past | cannot-add-second-future-pricing-info | cannot-build-actor-from-webhook | cannot-change-billing-interval | cannot-change-owner | cannot-charge-apify-event | cannot-charge-non-pay-per-event-actor | cannot-comment-as-other-user | cannot-copy-actor-task | cannot-create-payout | cannot-create-public-actor | cannot-create-tax-transaction | cannot-delete-critical-actor | cannot-delete-invoice | cannot-delete-paid-actor | cannot-disable-one-time-event-for-apify-start-event | cannot-disable-organization-with-enabled-members | cannot-disable-user-with-subscription | cannot-link-oauth-to-unverified-email | cannot-metamorph-to-pay-per-result-actor | cannot-modify-actor-pricing-too-frequently | cannot-modify-actor-pricing-with-immediate-effect | cannot-monetize-without-payout-billing-info | cannot-override-paid-actor-trial | cannot-permanently-delete-subscription | cannot-publish-actor | cannot-publish-actor-task | cannot-reduce-last-full-token | cannot-reimburse-more-than-original-charge | cannot-reimburse-non-rental-charge | cannot-remove-own-actor-from-recently-used | cannot-remove-payment-method | cannot-remove-pricing-info | cannot-remove-running-run | cannot-remove-user-with-public-actors | cannot-remove-user-with-subscription | cannot-remove-user-with-unpaid-invoice | cannot-rename-env-var | cannot-rent-paid-actor | cannot-review-own-actor | cannot-set-access-rights-for-owner | cannot-set-is-status-message-terminal | cannot-unpublish-critical-actor | cannot-unpublish-paid-actor | cannot-unpublish-profile | cannot-update-invoice-field | concurrent-runs-limit-exceeded | concurrent-update-detected | conference-token-not-found | content-encoding-forbidden-for-html | coupon-already-redeemed | coupon-expired | coupon-for-new-customers | coupon-for-subscribed-users | coupon-limits-are-in-conflict-with-current-limits | coupon-max-number-of-redemptions-reached | coupon-not-found | coupon-not-unique | coupons-disabled | create-github-issue-not-allowed | creator-plan-not-available | cron-expression-invalid | daily-ai-token-limit-exceeded | daily-publication-limit-exceeded | dataset-does-not-have-fields-schema | dataset-does-not-have-schema | dataset-locked | dataset-schema-invalid | dcr-not-supported | default-dataset-not-found | deleting-default-build | deleting-unfinished-build | email-already-taken | email-already-taken-removed-user | email-domain-not-allowed-for-coupon | email-invalid | email-not-allowed | email-not-valid | email-update-too-soon | elevated-permissions-needed | env-var-already-exists | exchange-rate-fetch-failed | expired-conference-token | failed-to-charge-user | final-invoice-negative | full-permission-actor-blocked-for-admin | full-permission-actor-not-approved | full-permissions-require-verified-owner | github-branch-empty | github-issue-already-exists | github-public-key-not-found | github-repository-not-found | github-signature-does-not-match-payload | github-user-not-authorized-for-issues | gmail-not-allowed | id-does-not-match | incompatible-billing-interval | incomplete-payout-billing-info | inconsistent-currencies | incorrect-pricing-modifier-prefix | input-json-invalid-characters | input-json-not-object | input-json-too-long | input-update-collision | input-validation-timed-out | insufficient-permissions | insufficient-permissions-to-change-field | insufficient-security-measures | insufficient-tax-country-evidence | integration-auth-error | internal-server-error | invalid-billing-info | invalid-billing-period-for-payout | invalid-build | invalid-client-key | invalid-collection | invalid-conference-login-password | invalid-content-type-header | invalid-credentials | invalid-git-auth-token | invalid-github-issue-url | invalid-header | invalid-id | invalid-idempotency-key | invalid-input | invalid-input-schema | invalid-invoice | invalid-invoice-type | invalid-issue-date | invalid-label-params | invalid-main-account-user-id | invalid-oauth-app | invalid-oauth-scope | invalid-one-time-invoice | invalid-parameter | invalid-payout-status | invalid-picture-url | invalid-record-key | invalid-request | invalid-resource-type | invalid-signature | invalid-subscription-plan | invalid-tax-number | invalid-tax-number-format | invalid-token | invalid-token-type | invalid-two-factor-code | invalid-two-factor-code-or-recovery-code | invalid-two-factor-recovery-code | invalid-username | invalid-value | invitation-invalid-resource-type | invitation-no-longer-valid | invoice-canceled | invoice-cannot-be-refunded-due-to-too-high-amount | invoice-incomplete | invoice-is-draft | invoice-locked | invoice-must-be-buffer | invoice-not-canceled | invoice-not-draft | invoice-not-found | invoice-outdated | invoice-paid-already | issue-already-connected-to-github | issue-not-found | issues-bad-request | issuer-not-registered | job-finished | label-already-linked | last-api-token | limit-reached | max-items-must-be-greater-than-zero | max-metamorphs-exceeded | max-total-charge-usd-below-minimum | max-total-charge-usd-must-be-greater-than-zero | mcp-connector-actor-not-allowed | method-not-allowed | migration-disabled | missing-actor-rights | missing-api-token | missing-billing-info | missing-line-items | missing-payment-date | missing-payout-billing-info | missing-proxy-password | missing-reporting-fields | missing-resource-name | missing-settings | missing-username | monthly-usage-limit-too-low | more-public-actors-require-verified-owner | more-than-one-update-not-allowed | multiple-records-found | must-be-admin | name-not-unique | next-runtime-computation-failed | no-columns-in-exported-dataset | no-payment-attempt-for-refund-found | no-payment-method-available | no-team-account-seats-available | non-temporary-email | not-enough-usage-to-run-paid-actor | not-implemented | not-supported-currencies | o-auth-service-already-connected | o-auth-service-not-connected | oauth-resource-access-failed | one-time-invoice-already-marked-paid | only-drafts-can-be-deleted | operation-canceled | operation-not-allowed | operation-timed-out | organization-cannot-own-itself | organization-role-not-found | overlapping-payout-billing-periods | own-token-required | page-not-found | param-not-one-of | parameter-required | parameters-mismatched | password-reset-email-already-sent | password-reset-token-expired | pay-as-you-go-without-monthly-interval | payment-attempt-status-message-required | payout-already-paid | payout-canceled | payout-invalid-state | payout-must-be-approved-to-be-marked-paid | payout-not-found | payout-number-already-exists | phone-number-invalid | phone-number-landline | phone-number-opted-out | phone-verification-disabled | platform-feature-disabled | price-overrides-validation-failed | pricing-model-not-supported | promotional-plan-not-available | proxy-auth-ip-not-unique | public-actor-disabled | query-timeout | quoted-price-outdated | rate-limit-exceeded | readme-required | recaptcha-invalid | recaptcha-required | record-not-found | record-not-public | record-or-token-not-found | record-too-large | redirect-uri-mismatch | reduced-plan-not-available | rental-charge-already-reimbursed | rental-not-allowed | request-aborted-prematurely | request-handled-or-locked | request-id-invalid | request-queue-duplicate-requests | request-too-large | requested-dataset-view-does-not-exist | resume-token-expired | run-failed | run-input-body-not-valid-json | run-timeout-exceeded | russia-is-evil | same-user | schedule-actor-not-found | schedule-actor-task-not-found | schedule-name-not-unique | schema-validation | schema-validation-error | schema-validation-failed | schemas-required | service-worker-registration-not-allowed | sign-up-method-not-allowed | slack-integration-not-custom | socket-closed | socket-destroyed | standby-deployment-invalid | store-schema-invalid | store-terms-not-accepted | stripe-enabled | stripe-generic-decline | stripe-not-enabled | stripe-not-enabled-for-user | tagged-build-required | tax-country-invalid | tax-number-invalid | tax-number-validation-failed | taxamo-call-failed | taxamo-request-failed | testing-error | token-not-provided | too-few-versions | too-many-actor-tasks | too-many-actors | too-many-labels-on-resource | too-many-mcp-connectors | too-many-o-auth-apps | too-many-organizations | too-many-public-actor-tasks-per-account | too-many-public-actor-tasks-per-actor | too-many-requests | too-many-schedules | too-many-ui-access-keys | too-many-user-labels | too-many-values | too-many-versions | too-many-webhooks | unexpected-route | unknown-build-tag | unknown-payment-provider | unsubscribe-token-invalid | unsupported-content-encoding | unsupported-file-type-for-issue | unsupported-file-type-image-expected | unsupported-file-type-text-or-json-expected | unsupported-permission | upcoming-subscription-bill-not-up-to-date | user-already-exists | user-already-verified | user-creates-organizations-too-fast | user-disabled | user-email-is-disposable | user-email-not-set | user-email-not-verified | user-has-no-subscription | user-integration-not-found | user-is-already-invited | user-is-already-organization-member | user-is-not-member-of-organization | user-is-not-organization | user-is-organization | user-is-organization-owner | user-is-removed | user-not-found | user-not-logged-in | user-not-verified | user-or-token-not-found | user-plan-not-allowed-for-coupon | user-problem-with-card | user-record-not-found | username-already-taken | username-missing | username-not-allowed | username-removal-forbidden | username-required | verification-email-already-sent | verification-token-expired | version-already-exists | versions-size-exceeded | weak-password | zero-invoice | AnyString

The type of the error, as returned by the API. Typed as the known ErrorType values for autocompletion, while still accepting any string the API may return.

### [](#stackTraceLimit)staticexternalinheritedstackTraceLimit

stackTraceLimit: number

Inherited from ApifyClientError.stackTraceLimit

The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured *after* the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

## Methods<!-- -->[](#Methods)

### [](#captureStackTrace)staticexternalinheritedcaptureStackTrace

* **captureStackTrace**(targetObject, constructorOpt): void

- Inherited from ApifyClientError.captureStackTrace

  Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()` was called.

  ```
  const myObject = {};

  Error.captureStackTrace(myObject);

  myObject.stack;  // Similar to `new Error().stack`
  ```

  The first line of the trace will be prefixed with `${myObject.name}: ${myObject.message}`.

  The optional `constructorOpt` argument accepts a function. If given, all frames above `constructorOpt`, including `constructorOpt`, will be omitted from the generated stack trace.

  The `constructorOpt` argument is useful for hiding implementation details of error generation from the user. For instance:

  ```
  function a() {

    b();

  }



  function b() {

    c();

  }



  function c() {

    // Create an error without stack trace to avoid calculating the stack trace twice.

    const { stackTraceLimit } = Error;

    Error.stackTraceLimit = 0;

    const error = new Error();

    Error.stackTraceLimit = stackTraceLimit;



    // Capture the stack trace above function b

    Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace

    throw error;

  }



  a();
  ```

  ***

  #### Parameters

  * ##### externaltargetObject: object
  * ##### externaloptionalconstructorOpt: Function

  #### Returns void

### [](#isError)staticexternalinheritedisError

* **isError**(error): error is Error

- Inherited from ApifyClientError.isError

  Indicates whether the argument provided is a built-in Error instance or not.

  ***

  #### Parameters

  * ##### externalerror: unknown

  #### Returns error is Error

### [](#prepareStackTrace)staticexternalinheritedprepareStackTrace

* **prepareStackTrace**(err, stackTraces): any

- Inherited from ApifyClientError.prepareStackTrace

  ***

  #### Parameters

  * ##### externalerr: Error
  * ##### externalstackTraces: CallSite\[]

  #### Returns any

  See more at <https://v8.dev/docs/stack-trace-api#customizing-stack-traces>
