---
page_title: Get an API token for HCP Terraform or Terraform Enterprise  
description: >-
  Use the `terraform login` and `terraform logout` commands get
  an API token for your HCP Terraform or Terraform Enterprise account.
---

# Get an API token for HCP Terraform and Terraform Enterprise

This topic describes how to use the `terraform login` and `terraform logout` to authenticate with HCP Terraform and Terraform Enterprise.

> **Hands-on:** Try the [Authenticate the CLI with HCP Terraform](/terraform/tutorials/cloud/cloud-login?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial.

## Overview

[HCP Terraform](https://cloud.hashicorp.com/products/terraform) and
[Terraform Enterprise](/terraform/enterprise) are platforms that perform
Terraform runs to provision infrastructure, offering a collaboration-focused
environment that makes it easier for teams to use Terraform together. 

You can integrate the Terraform CLI with HCP Terraform and Terraform Enterprise in the following ways: 

- Use the Terraform CLI as a front-end for [CLI-driven runs](/terraform/cloud-docs/run/cli) in HCP Terraform
- Use HCP Terraform or Terraform Enterprise as a state backend and a private module registry. 

These integrations require you to authenticate the Terraform CLI
with your HCP Terraform account.

## Authentication

Run the `terraform login` command to generate an API token for your HCP Terraform user account. Refer to the [`terraform login` command](/terraform/cli/commands/login) reference documentation for details.

Run the `terraform logout` command to end your HCP Terraform or Terraform Enterprise session. Refer to the [`terraform logout` command](/terraform/cli/commands/logout) reference documentation for details.
