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

# Connect Terraform with API Token – StackOne Hub

> Link a Terraform account in the StackOne Hub using API Token. End-user guide to authorize the integration and start using Terraform actions.

<Warning>Admin or Owner privileges are required in your Terraform account to generate API tokens.</Warning>

<section data-guide-section data-guide-scopes="">
  <h2>Determine Your Terraform Host</h2>

  <p>Identify your Terraform instance host based on your deployment type. This is the value you enter in the <strong>Terraform Host</strong> field in StackOne Hub.</p>

  <Steps>
    <Step title="Find Your Terraform Host">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Your <strong>Terraform Host</strong> depends on whether you use Terraform Cloud or Terraform Enterprise.</p>

        <ul>
          <li><strong>Terraform Cloud</strong> - Use `https://app.terraform.io`</li>
          <li><strong>Terraform Enterprise</strong> - Use your self-hosted instance URL</li>
          <li>Format: `https://{your-instance}.example.com`</li>
          <li>Example: `https://terraform.yourcompany.com`</li>
          <li>Paste this value into the <strong>Terraform Host</strong> field in StackOne Hub.</li>
        </ul>
      </div>
    </Step>
  </Steps>
</section>

<section data-guide-section data-guide-scopes="">
  <h2>Generate an API Token</h2>

  <p>Create a user API token to authenticate with the Terraform API.</p>

  <Steps>
    <Step title="Open Account Settings">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Sign in to your <a href="https://app.terraform.io" target="_blank" rel="noopener noreferrer">HCP Terraform account</a> or your Terraform Enterprise instance, then open your account settings.</p>

        <ul>
          <li>Click your user icon in the top-right corner</li>
          <li>Select <strong>Account settings</strong></li>
        </ul>
      </div>
    </Step>

    <Step title="Open the Tokens page">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>In the <strong>Account Settings</strong> sidebar, click <strong>Tokens</strong>, then click <strong>Create an API token</strong>.</p>

        <img src="https://mintcdn.com/stackone-60/uIHx_QC2fViT21bw/connectors/terraform/images/custom-config-create-api-token.png?fit=max&auto=format&n=uIHx_QC2fViT21bw&q=85&s=9520fb0db101782999eb9e0dc421e07f" alt="The Tokens page under Account Settings with the Create an API token button highlighted" width="1280" height="800" data-path="connectors/terraform/images/custom-config-create-api-token.png" />
      </div>
    </Step>

    <Step title="Create the token">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>In the <strong>Creating a user token</strong> dialog, fill in the details and generate the token.</p>

        <ul>
          <li>Enter a <strong>Description</strong> to help you identify this token later (e.g. `StackOne Integration`)</li>
          <li>Choose an <strong>Expiration</strong> for the token (the default is 30 days)</li>
          <li>Click <strong>Generate token</strong></li>
        </ul>

        <img src="https://mintcdn.com/stackone-60/uIHx_QC2fViT21bw/connectors/terraform/images/custom-config-generate-token.png?fit=max&auto=format&n=uIHx_QC2fViT21bw&q=85&s=5e8822abeeb0f6905cfebb37f843d27b" alt="The Creating a user token dialog with the Description and Expiration fields and the Generate token button highlighted" width="1280" height="800" data-path="connectors/terraform/images/custom-config-generate-token.png" />
      </div>
    </Step>

    <Step title="Copy and store the token">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>After you click <strong>Generate token</strong>, the new token is displayed inline on the <strong>Tokens</strong> page. Copy it and store it securely for use in StackOne.</p>

        <ul>
          <li>Copy the token from the <strong>Tokens</strong> page immediately using the copy button next to it</li>
          <li><strong>HCP Terraform will not display this token again, so store it securely.</strong> The token is shown once and cannot be retrieved later — if you lose it, you must delete it and create a new one.</li>
          <li>Paste the token into the <strong>API Token</strong> field in StackOne Hub.</li>
        </ul>

        <img src="https://mintcdn.com/stackone-60/uIHx_QC2fViT21bw/connectors/terraform/images/custom-config-copy-token.png?fit=max&auto=format&n=uIHx_QC2fViT21bw&q=85&s=745bd8864aa2d30d0de5d04a845235f0" alt="The newly created token shown inline on the Tokens page with the copy button and the store-securely warning" width="1280" height="800" data-path="connectors/terraform/images/custom-config-copy-token.png" />
      </div>
    </Step>
  </Steps>
</section>

<div data-whitelabel-hide>
  <h2>Linking the Account from the Hub</h2>

  <Steps>
    <Step title="Navigate to the Hub">
      Use one of the three <a href="/guides/accounts-section#linking-accounts">Linking Account Methods</a> to access the Hub.
    </Step>

    <Step title="Fill out the fields">
      Fill out the following fields using details from your provider:

      <ul>
        <li><strong>Terraform Host</strong></li>
        <li><strong>API Token</strong></li>
      </ul>
    </Step>

    <Step title="Connect">
      <ul>
        <li>Click <strong>Connect</strong></li>
        <li>If applicable, the provider will redirect you to a sign-in or authorization page. Complete the provider's authorization flow.</li>
        <li>Once authorization is successful, you will see a confirmation popup</li>
      </ul>
    </Step>
  </Steps>

  <p>If the account linking is successful, you will see the newly linked account in your <a href="/guides/accounts-section">Accounts</a> page.</p>
</div>
