An Ahrefs API request returning 403 Forbidden means the server refused the request but it does not necessarily mean your API token is invalid. The error can appear even when you have configured an API key and your integration previously worked.

The problem may involve endpoint permissions, subscription eligibility, API key restrictions or an authentication configuration that needs correcting. Replacing the API token without identifying the actual restriction may leave the same error unresolved.

Start by testing your API key against a documented free Ahrefs endpoint. If that request succeeds while your original endpoint returns 403, you can concentrate on access restrictions rather than repeatedly generating new credentials.

Identify Where the 403 Error Comes From

Before changing your Ahrefs settings, confirm that the error originates from the Ahrefs API rather than the application or service sending the request.

Some integrations display generic messages such as "Unauthorized," "Invalid API Token," or "Access Denied" without exposing the actual HTTP response. These messages can be misleading when the underlying request failed for a different reason.

Open the failed request in your API client, application logs or integration history. Check the destination URL, HTTP response code and response body to establish whether the request reached api.ahrefs.com.

Understand the HTTP response

Status codeMeaningWhat to investigate
200 OKRequest completed successfullyCompare with the failing request
400 Bad RequestRequest could not be processed as submittedParameters and request format
401 UnauthorizedAuthentication is missing or was rejectedAPI key and Authorization header
403 ForbiddenServer refuses the requested operationAuthorization and endpoint access
429 Too Many RequestsRequest was rate-limitedRequest frequency and throttling

A 401 response usually directs troubleshooting toward authentication, while a 403 response calls for investigating why the requested operation was refused. However, the precise cause must be established from the response details rather than the status code alone.

If you have confirmed that the request is failing against Ahrefs API v3, proceed with the authentication test.

Step 1: Test Your API Key Against a Free Ahrefs Endpoint

The first test should determine whether Ahrefs accepts your API key for a known operation.

Ahrefs provides a free Domain Rating endpoint that requires an API v3 key but does not consume API units. This makes it a useful diagnostic endpoint because you can test the credential without spending your paid API allowance.

Prepare your API key

Open Ahrefs and navigate to Account Settings → API Keys. Use an existing key that you are authorized to manage, or ask the workspace administrator to provide an appropriate credential through a secure channel.

Store the key in an environment variable rather than placing it directly inside a command that might be saved or shared.

For macOS and Linux

Open Terminal and run:

printf "Ahrefs API key: "
IFS= read -r -s AHREFS_API_KEY
printf '\n'
export AHREFS_API_KEY

The command accepts your API key without displaying the characters as you type. It is suitable for Bash and Zsh, including the default shell used by modern macOS systems.

For Windows PowerShell

Open PowerShell and run:

$secureKey = Read-Host "Ahrefs API key" -AsSecureString

$env:AHREFS_API_KEY = [System.Net.NetworkCredential]::new("", $secureKey).Password

The credential will be available to commands running in the current terminal session. Close the session after troubleshooting and avoid exposing the environment variable to untrusted applications.

Send the API request

For macOS or Linux:

curl -i \
  "https://api.ahrefs.com/v3/public/domain-rating-free?target=ahrefs.com" \
  -H "Authorization: Bearer ${AHREFS_API_KEY}" \
  -H "Accept: application/json"

For Windows PowerShell:

curl.exe -i "https://api.ahrefs.com/v3/public/domain-rating-free?target=ahrefs.com" -H "Authorization: Bearer $env:AHREFS_API_KEY" -H "Accept: application/json"

The -i option displays the HTTP response headers, making it easier to identify the actual status returned by Ahrefs.

Interpret the test result

If the request returns 200 OK, your key has successfully authenticated for the public endpoint. This establishes that basic API authentication works for that operation, although access to paid endpoints must still be checked separately.

If the response returns 401 Unauthorized, continue to Step 2 and verify the Authorization header. An incorrect or inactive credential may be responsible.

If the public endpoint also returns 403 Forbidden, inspect the response body before changing the key. Continue through the credential checks to determine whether the rejection is associated with the account or authorization configuration.

The purpose of this test is to establish whether the failure affects basic authentication or only certain API operations.

Step 2: Check the Authorization Header

Ahrefs API v3 uses Bearer authentication. Even when the correct API key is saved in an application, the request can fail if the application sends an incorrectly formatted header.

The required format is:

Authorization: Bearer YOUR_API_KEY

An integration may add the Bearer prefix automatically. If you also include that prefix in a field intended only for the key, the application may construct an incorrect Authorization header.

Verify the request configuration

  1. Open the API connection settings in the application returning the error.

  2. Locate the authentication method and stored API credential.

  3. Check whether the application automatically adds the Bearer prefix.

  4. Confirm that the outgoing request contains one correctly formatted Authorization header.

  5. Verify that the application uses the intended API key rather than an outdated credential.

  6. Save the configuration and repeat the free endpoint test from Step 1.

If you are using environment variables, confirm that the application can actually access the variable containing the key.

A local test may work while a production integration fails because the deployed server, container or scheduled job does not have the same environment configuration.

If the authentication test succeeds after correcting the header, retry your original API request. If the original endpoint still returns 403, leave the working authentication configuration unchanged and investigate the status of the key itself.

Step 3: Verify API Key Expiration and Ownership

An Ahrefs API key may stop working after an expiration date or a change to workspace membership.

Ahrefs allows workspace Owners and Admins to manage API keys through Account Settings. The interface shows each key's expiration date and the user who created it.

A particularly important restriction is that Ahrefs invalidates an API key when the user who created it is removed from the workspace.

This means an integration that worked previously may lose access after an employee, contractor or administrator leaves the workspace.

Inspect the API key

Ask a workspace Owner or Admin to complete these checks:

  1. Sign in to the Ahrefs workspace associated with the integration.

  2. Open Account Settings → API Keys.

  3. Locate the key associated with the failing application.

  4. Check whether the key has reached its expiration date.

  5. Identify the user who originally created it.

  6. Confirm that the creator remains a member of the workspace.

  7. Review any API usage restrictions assigned to the key.

If the key has expired or was invalidated, an authorized administrator should create a replacement and update the application's credential configuration.

After replacing it, repeat the free API test. If the request succeeds, test the original endpoint to determine whether the replacement also resolves the reported failure.

What if the key is still valid?

If the key remains active and works against the free endpoint, do not generate another replacement merely because a paid endpoint returns 403.

A working credential can still lack access to particular API operations. The next step is to check whether the endpoint is available under your subscription.

Step 4: Check Endpoint Access and Subscription Eligibility

Having an API key does not automatically provide access to every Ahrefs API endpoint.

Ahrefs allows API v3 keys to be generated for certain free public operations. Broader API functionality depends on subscription eligibility and the restrictions associated with specific endpoints.

This distinction matters when the free Domain Rating test succeeds but your application cannot retrieve Site Explorer, Keywords Explorer or other API data.

Verify the endpoint requirements

  1. Open the failed request in your application logs.

  2. Copy the endpoint path without including your API key.

  3. Find the corresponding endpoint in the official Ahrefs API v3 reference.

  4. Check the required HTTP method and parameters.

  5. Review whether the endpoint has subscription or authorization restrictions.

  6. Compare those requirements with your workspace's active subscription.

If the endpoint requires capabilities unavailable under your subscription, generating another key will not remove that restriction.

The appropriate solution is to use an endpoint supported by your existing plan or consider a subscription that provides the necessary access.

However, do not assume that every 403 error requires an Enterprise subscription. Standard Ahrefs API functionality is available on eligible paid plans, while certain specialized capabilities may have additional restrictions.

Test the endpoint without unnecessary API charges

Ahrefs provides free test queries for selected API operations on paid plans.

For Site Explorer endpoints, documented test targets include:

  • ahrefs.com

  • yep.com

  • firehose.com

Certain Keywords Explorer operations also support designated test keywords.

Check the exact endpoint's documentation before sending a test request. Free-query conditions differ between operations and including additional unsupported targets or keywords can consume API units.

If a documented free test works but your normal request returns 403, compare the parameters and restrictions of the two requests.

If the permitted test request also returns 403, record the response details and continue investigating the account's API allowances.

Step 5: Check API Unit Limits and Restrictions

Ahrefs allows administrators to control how many API units individual keys can consume. The workspace also has an API allowance determined by its subscription and applicable usage settings.

A key-level restriction may affect one integration even when the workspace has remaining API units.

However, an exhausted allowance should not automatically be treated as the explanation for a 403 response. The returned error details are needed to establish whether usage restrictions are involved.

Retrieve your API usage information

Ahrefs provides a subscription-information endpoint that reports API usage and applicable limits without consuming API units.

For macOS or Linux:

curl -i \
  "https://api.ahrefs.com/v3/subscription-info/limits-and-usage" \
  -H "Authorization: Bearer ${AHREFS_API_KEY}" \
  -H "Accept: application/json"

For Windows PowerShell:

curl.exe -i "https://api.ahrefs.com/v3/subscription-info/limits-and-usage" -H "Authorization: Bearer $env:AHREFS_API_KEY" -H "Accept: application/json"

If the request succeeds, the response includes a limits_and_usage object containing subscription information, key expiration, usage counters and applicable limits.

Check the relevant fields

Response fieldWhat it tells you
api_key_expiration_dateWhen the API key expires
subscriptionThe subscription associated with the API request
units_limit_api_keyMonthly allowance assigned to the API key
units_usage_api_keyUnits consumed by that key
units_limit_workspaceReported workspace unit allowance
units_usage_workspaceUnits consumed across the workspace
usage_reset_dateDate the next usage period begins

Some values may return null. For example, Ahrefs documents null as an unlimited value for units_limit_api_key, so it should not be interpreted as zero available units.

If the key has reached its configured allowance, ask the workspace administrator to review the key settings under Account Settings → API Keys.

Workspace-level allowances and pay-as-you-go settings can be reviewed separately through Account Settings → Limits & Usage.

If the reported usage is within the applicable limits, do not purchase additional units without establishing why the original request was refused.

If the limits-and-usage request also fails, record its status code and response body. That result helps establish whether the problem affects more than the original data endpoint.

Does the Integration Use Ahrefs Connect?

This check applies only to applications using Ahrefs Connect through OAuth authorization rather than a directly configured API key.

Ahrefs Connect uses access tokens issued after a user authorizes an application. These tokens have a documented one-year lifetime and Ahrefs does not issue refresh tokens for this authorization flow.

If an OAuth-based connection has expired, the user must authorize the application again.

Open the application's connection settings and check whether the Ahrefs authorization remains active. If necessary, reconnect the account using the application's supported OAuth process.

For an integration still in development, also verify its approval and activation status. An application that has not been activated may have access restrictions that differ from those of an approved production integration.

If your application uses an ordinary API v3 key, this OAuth check is not relevant. Continue troubleshooting that key without changing unrelated application connections.

What If the API Still Returns 403?

If the request remains forbidden after completing the relevant checks, use the results to identify which part of the connection is still failing.

The important distinction is whether the error affects all tested requests or only the original endpoint.

Troubleshooting resultWhat to investigate next
Free endpoint returns 401Authentication header and API key validity
Free endpoint returns 200, original endpoint returns 403Subscription eligibility and endpoint authorization
API key has expiredGenerate and configure a replacement
API key creator was removedReplace the invalidated credential
API unit allowance is exhaustedReview key and workspace limits
Free test query succeeds, normal request failsCompare request parameters and operation restrictions
Multiple documented endpoints return 403Collect response details for account-specific investigation

Compare the original request with the API documentation

If the original endpoint still fails despite apparently valid authentication and sufficient API access, compare the complete request against the official reference.

Check the HTTP method, endpoint path, required parameters, and supported request format. An integration using outdated API paths or unsupported parameters must be corrected before the failure can be reliably diagnosed.

If your application sends requests through a proxy or intermediary service, determine whether the same request behaves differently when sent directly to Ahrefs.

Do not expose your API key while testing or include it in application logs.

If the documented request continues to return 403, the remaining problem may require investigation by Ahrefs Support.

Contact Ahrefs Support With the Failed Request Details

An unresolved API authorization error is easier to investigate when you provide the exact request information and the results of your previous tests.

Rather than reporting only that the API token is unauthorized, include evidence showing which operations succeeded and which were denied.

Prepare the following details:

  1. The exact API endpoint returning 403, excluding credentials.

  2. The HTTP method used by the application.

  3. The response status and sanitized error body.

  4. The result of the free Domain Rating endpoint test.

  5. The result of the limits-and-usage request.

  6. The subscription associated with the affected workspace.

  7. Any relevant recent API key, membership, or deployment changes.

Contact Ahrefs through its official support channels and explain which checks have already been completed.

Never share the actual API key, a complete Authorization header, OAuth tokens or other account secrets in publicly accessible support discussions.

If Ahrefs identifies an account restriction or configuration issue, apply the recommended correction before repeating the failed operation.

Verify That the Original API Request Works

After correcting the identified problem, repeat the API request that originally returned 403.

Use the same endpoint, HTTP method and required parameters so that you are testing the actual operation that failed rather than a different API feature.

A successful free endpoint test establishes that basic authentication works but the original request must succeed before you can conclude that the integration problem has been resolved.

If the application runs on a production server, confirm that the updated credentials or configuration have been deployed to that environment. An API call that succeeds on your local computer does not prove that the server is using the same settings.

Finally, check whether the successful request returned the expected data and review its API unit consumption. Avoid unnecessary repeated tests against chargeable endpoints once the connection is functioning correctly.

The correct resolution for an Ahrefs API 403 error depends on what the server is refusing. Testing authentication, endpoint eligibility and API usage separately helps you identify the relevant restriction without changing unrelated settings.

For other Ahrefs software problems, BusinessTally's Ahrefs troubleshooting library provides guides organized around specific features and errors.