Issue

When you run script or code to call an Unstructured API, you get one of the following warnings or errors:

UserWarning: If intending to use the paid API, please define `server_url` in your request.
ERROR: Server responded with 404 - {"detail":"Not Found"}

You also get the following related warnings or errors in your logs:

SDKError: API error occurred: Status 401
{"detail":"API key is malformed, please type the API key correctly in the header."}
API error occurred: Status 404
{"detail":"Not Found"}

Possible causes

  1. The Unstructured API key, Unstructured API URL, or both are missing or malformed in your script or code.
  2. The API key, API URL, or both are not present in your current session.
  3. The API key is no longer valid, or the API key and API URL combination is not valid.

Suggested solutions

For the API URL, note the following:

  • For the Unstructured Platform API, the API URL is typically https://platform.unstructuredapp.io, which is unique to the Unstructured Python SDK; and https://platform.unstructuredapp.io/api/v1 for standard REST-enabled utilities (such as curl), tools (such as Postman), programming languages, packages, and libraries.
  • For the Unstructured Serverless API, the API URL is typically https://api.unstructuredapp.io, which is unique to the Unstructured Python SDK, beginning with 0.30.0; and https://api.unstructuredapp.io/general/v0/general for the Unstructured Python SDK before 0.30.0 and for standard REST-enabled utilities (such as curl), tools (such as Postman), programming languages, packages, and libraries. Be aware of the inclusion of app in this API URL.
  • For the Free Unstructured API, the API URL is typically https://api.unstructured.io`, which is unique to the Unstructured Python SDK, beginning with 0.30.0; and https://api.unstructured.io/general/v0/general for the Unstructured Python SDK before 0.30.0 and for standard REST-enabled utilities (such as curl), tools (such as Postman), programming languages, packages, and libraries. Be aware that there is no app in this API URL.
The free 14-day trial of the Unstructured Serverless API or Unstructured Platform API is different than the Free Unstructured API.

For the API key, note the following:

  • For the Unstructured Serverless API or the Unstructured Platform API, the API key is in your dashboard. To access your dashboard:

    1. Sign in to your Unstructured account.
    2. At the bottom of the sidebar, click your user icon, and then click Account Settings.
    3. On the API Keys tab, note the value of the Unstructured Serverless API URL or the Unstructured Platform API URL.

    Important: For the Unstructured Python SDK beginning with 0.30.0:

    • For the Unstructured Platform API URL, do not use https://platform.unstructuredapp.io/api/v1, or else calls made by the Python SDK will fail. Use https://platform.unstructuredapp.io instead.
    • For the Unstructured Serverless API URL, do not use https://api.unstructuredapp.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructuredapp.io instead.
    • For the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.
  • For the Free Unstructured API, the API key is in your original email from Unstructured. If you cannot find the original email, you can regenerate it by going to https://unstructured.io/api-key-free.

    Important: For the Unstructured Python SDK beginning with 0.30.0,
    for the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.

The free 14-day trial of the Unstructured Serverless API or Unstructured Platform API is different than the Free Unstructured API.

If you still believe you have the correct API URL and API key, try the following steps:

  1. Check your script or code to see where the API URL and API key are specified, as follows:

    For a POST request to the Unstructured API

    • Check the target URL. Make sure it is set to the right API URL.
    • Check the value of the unstructured-api-key header. Make sure it is set to the right API key, or an environment variable representing the right API key.

    For the Unstructured Python SDK (Unstructured Platform API, Unstructured Serverless API, and Free Unstructured API only)

    • For the Unstructured Python SDK beginning with 0.30.0, if the server_url parameter is in your UnstructuredClient constructor, move it into your operational calling function such as partition or partition_asyc for Unstructured API services or list_*, get_*, create_*, update_*, or delete_* for the Unstructured Platform API. For example:

      # Instead of this (before Python SDK 0.30.0):
      client = unstructured_client.UnstructuredClient(
          api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
          server_url=os.getenv("UNSTRUCTURED_API_URL")
      )
      
      # Switch to this (beginning with Python SDK 0.30.0):
      client = unstructured_client.UnstructuredClient(
          api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
      )
      
      # And then...
      
      # For Unstructured API services:
      res = client.general.<partition|partition_async>(
          request=req,
          server_url=os.getenv("UNSTRUCTURED_API_URL")
      )
      
      # Or for the Unstructured Platform API:
      res = client.<sources-destinations-workflows-jobs>.<list-get-create-delete-operation>(
          request=req,
          server_url=os.getenv("UNSTRUCTURED_API_URL")
      )
      
    • Check the value of the server_url parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL.

      Important: For the Unstructured Python SDK beginning with 0.30.0:

      • For the Unstructured Platform API URL, do not use https://platform.unstructuredapp.io/api/v1, or else calls made by the Python SDK will fail. Use https://platform.unstructuredapp.io instead.
      • For the Unstructured Serverless API URL, do not use https://api.unstructuredapp.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructuredapp.io instead.
      • For the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.
    • Check the value of the api_key_auth parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.

    For the Unstructured JavaScript/TypeScript SDK (Unstructured Serverless API and Free Unstructured API only)

    • Check the value of the UnstructuredClient object’s serverURL or server parameter:

      • For serverURL, make sure it is set to the right API URL, or an environment variable representing the right API URL, or…

      • For server, make sure it is set to "saas-api" for the Unstructured Serverless API, or "free-api" for the Free Unstructured API, or an environment variable representing one of these strings.

        You can use "saas-api" and "free-api" only with the Unstructured JavaScript/TypeScript SDK.
      • Make sure that only serverURL or server are specified—not both.

      • Make sure that if you specify serverURL, an actual API URL (or an environment variable representing an actual API URL) is specified (not "saas-api" or "free-api", or an environment variable representing one of these strings).

      • Make sure that if you specify server, an actual API URL is not specified (it must be only "saas-api" or "free-api", or an environment variable representing one of these strings).

    • Check the value of the UnstructuredClient object’s security: { apiKeyAuth } parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.

    For the Unstructured Ingest CLI (Unstructured Serverless API and Free Unstructured API only)

    • Check the value of the --partition-endpoint command option. Make sure it is set to the right API URL, or an environment variable representing the right API URL.
    • Check the value of the --api-key command option. Make sure it is set to the right API key, or an environment variable representing the right API key.

    For the Unstructured Ingest Python library (Unstructured Serverless API and Free Unstructured API only)

    For a v2 connector implementation, check the value of the partitioner_config parameter in the Pipeline.from_configs method. This parameter should be set to a PartitionerConfig object:

    • Check the object’s partition_endpoint parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL.
    • Check the object’s api_key parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.

    For a v1 connector implementation, check the value of the partition_config parameter in the Runner object. This parameter should be set to a PartitionConfig object:

    • Check the object’s partition_endpoint parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL.
    • Check the object’s api_key parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.

    For the Unstructured open source library (Unstructured Serverless API and Free Unstructured API only)

    • Check the value of the partition_by_api command’s api_url parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL.
    • Check the value of the partition_by_api command’s api_key parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.
  2. If you follow the recommended approach to use environment variables to represent the API key and API URL instead of hard-coding them into your script or code, check your session to see if these environment variables have been loaded, for example:

    • Run the command for your operating system to list all environment variables. Make sure the API key and API URL are listed and are set to the right ones. Make sure the names and cases of these environment variables match the ones in your script or code exactly.
    • If you use an integrated development environment (IDE) to run your script or code, check the IDE’s documentation for how to specify and load environment variables at run time or debug time. Make sure the names and cases of these environment variables match the ones in your script or code exactly.
  3. Re-verify the API key and API URL that you want to use:

    For the Unstructured Serverless API and Unstructured Platform API

    1. Sign in to your Unstructured account.

    2. At the bottom of the sidebar, click your user icon, and then click Account Settings.

    • Make sure that the API key you want to use matches the one in your script, code, or environment variable. To get the full API key value, click the Copy icon. Paste it to a temporary location for you to compare to your the one in your script, code, or environment variable. After you make the comparison, make sure to immediately delete from that temporary location what you just pasted.
    • Make sure the Unstructured Serverless API URL or the Unstructured Platform API URL matches the one in your script, code, or environment variable.

    Important: For the Unstructured Python SDK beginning with 0.30.0:

    • For the Unstructured Platform API URL, do not use https://platform.unstructuredapp.io/api/v1, or else calls made by the Python SDK will fail. Use https://platform.unstructuredapp.io instead.
    • For the Unstructured Serverless API URL, do not use https://api.unstructuredapp.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructuredapp.io instead.

    For the Free Unstructured API

    • Open your original email from Unstructured that contains your API key. Make sure it matches the one in your script, code, or environment variable. If you cannot find the original email, you can regenerate it by going to https://unstructured.io/api-key-free.
    • Make sure that you are using https://api.unstructured.io/general/v0/general (not platform.unstructuredapp.io or api.unstructuredapp.io) for the API URL.

    Important: For the Unstructured Python SDK beginning with 0.30.0 for the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.

  4. If you are still getting this issue, contact us directly.