• Overview
    • Enforce Policy as Code
    • Infrastructure as Code
    • Inject Secrets into Terraform
    • Integrate with Existing Workflows
    • Manage Kubernetes
    • Manage Virtual Machine Images
    • Multi-Cloud Deployment
    • Network Infrastructure Automation
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
  • Registry
  • Tutorials
    • About the Docs
    • Intro to Terraform
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
    • Terraform Tools
    • CDK for Terraform
    • Glossary
  • Community
GitHubTerraform Cloud
Download

    Terraform Cloud and Enterprise

  • Overview
  • Plans and Features
  • Getting Started
    • API Docs template
    • Overview
    • Account
    • Agent Pools
    • Agent Tokens
    • Applies
    • Audit Trails
    • Comments
    • Configuration Versions
    • Cost Estimates
    • Feature Sets
    • Invoices
    • IP Ranges
    • Notification Configurations
    • OAuth Clients
    • OAuth Tokens
    • Organizations
    • Organization Memberships
    • Organization Tags
    • Organization Tokens
    • Plan Exports
    • Plans
    • Policies
    • Policy Checks
    • Policy Sets
    • Policy Set Parameters
      • Modules
      • Providers
      • Private Provider Versions and Platforms
      • GPG Keys
    • Runs
      • Run Tasks
      • Stages and Results
      • Custom Integration
    • Run Triggers
    • SSH Keys
    • State Versions
    • State Version Outputs
    • Subscriptions
    • Team Access
    • Team Membership
    • Team Tokens
    • Teams
    • User Tokens
    • Users
    • Variables
    • VCS Events
    • Workspaces
    • Workspace-Specific Variables
    • Workspace Resources
    • Variable Sets
      • Overview
      • Module Sharing
      • Organizations
      • Runs
      • Settings
      • Terraform Versions
      • Users
      • Workspaces
    • Changelog
    • Stability Policy
    • Overview
    • Creating Workspaces
    • Naming
    • Terraform Configurations
      • Overview
      • Managing Variables
      • Overview
      • VCS Connections
      • Access
      • Drift Detection
      • Notifications
      • SSH Keys for Modules
      • Run Triggers
      • Run Tasks
    • Terraform State
    • JSON Filtering
    • Remote Operations
    • Viewing and Managing Runs
    • Run States and Stages
    • Run Modes and Options
    • UI/VCS-driven Runs
    • API-driven Runs
    • CLI-driven Runs
    • The Run Environment
    • Installing Software
    • Users
    • Teams
    • Organizations
    • Permissions
    • Two-factor Authentication
    • API Tokens
      • Overview
      • Microsoft Azure AD
      • Okta
      • SAML
      • Linking a User Account
      • Testing
    • Overview
    • GitHub.com
    • GitHub.com (OAuth)
    • GitHub Enterprise
    • GitLab.com
    • GitLab EE and CE
    • Bitbucket Cloud
    • Bitbucket Server and Data Center
    • Azure DevOps Services
    • Azure DevOps Server
    • Troubleshooting
    • Overview
    • Adding Public Providers and Modules
    • Publishing Private Providers
    • Publishing Private Modules
    • Using Providers and Modules
    • Configuration Designer
  • Migrating to Terraform Cloud
    • Overview
    • Using Sentinel with Terraform 0.12
    • Manage Policies
    • Enforce and Override Policies
    • Mocking Terraform Sentinel Data
    • Working With JSON Result Data
      • Overview
      • tfconfig
      • tfconfig/v2
      • tfplan
      • tfplan/v2
      • tfstate
      • tfstate/v2
      • tfrun
    • Example Policies
    • Overview
    • AWS
    • GCP
    • Azure
      • Overview
      • Service Catalog
      • Admin Guide
      • Developer Reference
      • Example Customizations
      • V1 Setup Instructions
    • Splunk Integration
    • Kubernetes Integration
    • Run Tasks Integration
    • Overview
    • IP Ranges
    • Data Security
    • Security Model
    • Overview
    • Part 1: Overview of Our Recommended Workflow
    • Part 2: Evaluating Your Current Provisioning Practices
    • Part 3: How to Evolve Your Provisioning Practices
    • Part 3.1: From Manual Changes to Semi-Automation
    • Part 3.2: From Semi-Automation to Infrastructure as Code
    • Part 3.3: From Infrastructure as Code to Collaborative Infrastructure as Code
    • Part 3.4: Advanced Workflow Improvements

  • Terraform Cloud Agents

  • Terraform Enterprise Admin

  • Other Docs

  • Intro to Terraform
  • Configuration Language
  • Terraform CLI
  • Terraform Cloud
  • Terraform Enterprise
  • Provider Use
  • Plugin Development
  • Registry Publishing
  • Integration Program
  • Terraform Tools
  • CDK for Terraform
  • Glossary
Type '/' to Search

»Organization Memberships API

Users are added to organizations by inviting them to join. Once accepted, they become members of the organization. The Organization Membership resource represents this membership.

You can invite users who already have an account, as well as new users. If the user has an existing account with the same email address used to invite them, they can reuse the same login.

Note: Once a user is a member of the organization, you can manage their team memberships using the Team Membership API.

»Invite a User to an Organization

POST /organizations/:organization_name/organization-memberships

ParameterDescription
:organization_nameThe name of the organization the user will be invited to join. The inviting user must have permission to manage organization memberships.

Note: Organization membership management is restricted to members of the owners team, the owners team API token, and the organization API token.

StatusResponseReason
201JSON API documentSuccessfully invited the user
400JSON API error objectUnable to invite user due to organization limits
404JSON API error objectOrganization not found, or user unauthorized to perform action
422JSON API error objectUnable to invite user due to validation errors

»Request Body

This POST endpoint requires a JSON object with the following properties as a request payload.

Properties without a default value are required.

Key pathTypeDefaultDescription
data.typestringMust be "organization-memberships".
data.attributes.emailstringThe email address of the user to be invited.
data.relationships.teams.data[]array[object]A list of resource identifier objects that defines which teams the invited user will be a member of. These objects must contain id and type properties, and the type property must be teams (e.g. { "id": "team-GeLZkdnK6xAVjA5H", "type": "teams" }). Obtain team IDs from the List Teams endpoint. All users must be added to at least one team.

»Sample Payload

{
  "data": {
    "attributes": {
      "email": "test@example.com"
    },
    "relationships": {
      "teams": {
        "data": [
          {
            "type": "teams",
            "id": "team-GeLZkdnK6xAVjA5H"
          }
        ]
      }
    },
    "type": "organization-memberships"
  }
}
{
  "data": {
    "attributes": {
      "email": "test@example.com"
    },
    "relationships": {
      "teams": {
        "data": [
          {
            "type": "teams",
            "id": "team-GeLZkdnK6xAVjA5H"
          }
        ]
      }
    },
    "type": "organization-memberships"
  }
}

»Sample Request

$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  --data @payload.json \
  https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships
$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  --data @payload.json \
  https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships

»Sample Response

{
  "data": {
    "id": "ou-nX7inDHhmC3quYgy",
    "type": "organization-memberships",
    "attributes": {
      "status": "invited"
    },
    "relationships": {
      "teams": {
        "data": [
          {
            "id": "team-GeLZkdnK6xAVjA5H",
            "type": "teams"
          }
        ]
      },
      "user": {
        "data": {
          "id": "user-J8oxGmRk5eC2WLfX",
          "type": "users"
        }
      },
      "organization": {
        "data": {
          "id": "my-organization",
          "type": "organizations"
        }
      }
    }
  },
  "included": [
    {
      "id": "user-J8oxGmRk5eC2WLfX",
      "type": "users",
      "attributes": {
        "username": null,
        "is-service-account": false,
        "avatar-url": "https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=100&d=mm",
        "two-factor": {
          "enabled": false,
          "verified": false
        },
        "email": "test@example.com",
        "permissions": {
          "can-create-organizations": true,
          "can-change-email": true,
          "can-change-username": true,
          "can-manage-user-tokens": false
        }
      },
      "relationships": {
        "authentication-tokens": {
          "links": {
            "related": "/api/v2/users/user-J8oxGmRk5eC2WLfX/authentication-tokens"
          }
        }
      },
      "links": {
        "self": "/api/v2/users/user-J8oxGmRk5eC2WLfX"
      }
    }
  ]
}
{
  "data": {
    "id": "ou-nX7inDHhmC3quYgy",
    "type": "organization-memberships",
    "attributes": {
      "status": "invited"
    },
    "relationships": {
      "teams": {
        "data": [
          {
            "id": "team-GeLZkdnK6xAVjA5H",
            "type": "teams"
          }
        ]
      },
      "user": {
        "data": {
          "id": "user-J8oxGmRk5eC2WLfX",
          "type": "users"
        }
      },
      "organization": {
        "data": {
          "id": "my-organization",
          "type": "organizations"
        }
      }
    }
  },
  "included": [
    {
      "id": "user-J8oxGmRk5eC2WLfX",
      "type": "users",
      "attributes": {
        "username": null,
        "is-service-account": false,
        "avatar-url": "https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=100&d=mm",
        "two-factor": {
          "enabled": false,
          "verified": false
        },
        "email": "test@example.com",
        "permissions": {
          "can-create-organizations": true,
          "can-change-email": true,
          "can-change-username": true,
          "can-manage-user-tokens": false
        }
      },
      "relationships": {
        "authentication-tokens": {
          "links": {
            "related": "/api/v2/users/user-J8oxGmRk5eC2WLfX/authentication-tokens"
          }
        }
      },
      "links": {
        "self": "/api/v2/users/user-J8oxGmRk5eC2WLfX"
      }
    }
  ]
}

»List Memberships for an Organization

GET /organizations/:organization_name/organization-memberships

ParameterDescription
:organization_nameThe name of the organization to list the memberships of.

»Query Parameters

This endpoint supports pagination with standard URL query parameters. Remember to percent-encode [ as %5B and ] as %5D if your tooling doesn't automatically encode URLs.

ParameterDescription
qOptional. A search query string. Organization memberships are searchable by user name and email.
filter[status]Optional. If specified, restricts results to those with the matching status value. Valid values are invited and active.
filter[email]Optional. If specified, restricts results to those with a matching user email address. If multiple comma separated values are specified, results matching any of the values are returned.
page[number]Optional. If omitted, the endpoint will return the first page.
page[size]Optional. If omitted, the endpoint will return 20 users per page.

»Sample Request

$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships
$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships

»Sample Response

{
  "data": [
    {
      "id": "ou-tTJph1AQVK5ZmdND",
      "type": "organization-memberships",
      "attributes": {
        "status": "active"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-vaQqszES9JnuK4eB",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    },
    {
      "id": "ou-D6HPYFt4GzeBt3gB",
      "type": "organization-memberships",
      "attributes": {
        "status": "active"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-oqCgH7NgTn95jTGc",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    },
    {
      "id": "ou-x1E2eBwYwusLDC7h",
      "type": "organization-memberships",
      "attributes": {
        "status": "invited"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-UntUdBTHsVRQMzC8",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    }
  ],
  "links": {
    "self": "https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "first": "https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "prev": null,
    "next": null,
    "last": "https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships?page%5Bnumber%5D=1&page%5Bsize%5D=20"
  },
  "meta": {
    "status-counts": {
      "total": 3,
      "active": 2,
      "invited": 1
    },
    "pagination": {
      "current-page": 1,
      "prev-page": null,
      "next-page": null,
      "total-pages": 1,
      "total-count": 3
    }
  }
}
{
  "data": [
    {
      "id": "ou-tTJph1AQVK5ZmdND",
      "type": "organization-memberships",
      "attributes": {
        "status": "active"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-vaQqszES9JnuK4eB",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    },
    {
      "id": "ou-D6HPYFt4GzeBt3gB",
      "type": "organization-memberships",
      "attributes": {
        "status": "active"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-oqCgH7NgTn95jTGc",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    },
    {
      "id": "ou-x1E2eBwYwusLDC7h",
      "type": "organization-memberships",
      "attributes": {
        "status": "invited"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-UntUdBTHsVRQMzC8",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    }
  ],
  "links": {
    "self": "https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "first": "https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "prev": null,
    "next": null,
    "last": "https://app.terraform.io/api/v2/organizations/my-organization/organization-memberships?page%5Bnumber%5D=1&page%5Bsize%5D=20"
  },
  "meta": {
    "status-counts": {
      "total": 3,
      "active": 2,
      "invited": 1
    },
    "pagination": {
      "current-page": 1,
      "prev-page": null,
      "next-page": null,
      "total-pages": 1,
      "total-count": 3
    }
  }
}

»List User's Own Memberships

GET /organization-memberships

»Sample Request

$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  https://app.terraform.io/api/v2/organization-memberships
$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  https://app.terraform.io/api/v2/organization-memberships

»Sample Response

{
  "data": [
    {
      "id": "ou-VgJgfbDVN3APUm2F",
      "type": "organization-memberships",
      "attributes": {
        "status": "invited"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-4QrJKzxB3J5N4cJc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-vaQqszES9JnuK4eB",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "acme-corp",
            "type": "organizations"
          }
        }
      }
    },
    {
      "id": "ou-tTJph1AQVK5ZmdND",
      "type": "organization-memberships",
      "attributes": {
        "status": "active"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-vaQqszES9JnuK4eB",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    }
  ]
}
{
  "data": [
    {
      "id": "ou-VgJgfbDVN3APUm2F",
      "type": "organization-memberships",
      "attributes": {
        "status": "invited"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-4QrJKzxB3J5N4cJc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-vaQqszES9JnuK4eB",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "acme-corp",
            "type": "organizations"
          }
        }
      }
    },
    {
      "id": "ou-tTJph1AQVK5ZmdND",
      "type": "organization-memberships",
      "attributes": {
        "status": "active"
      },
      "relationships": {
        "teams": {
          "data": [
            {
              "id": "team-yUrEehvfG4pdmSjc",
              "type": "teams"
            }
          ]
        },
        "user": {
          "data": {
            "id": "user-vaQqszES9JnuK4eB",
            "type": "users"
          }
        },
        "organization": {
          "data": {
            "id": "my-organization",
            "type": "organizations"
          }
        }
      }
    }
  ]
}

»Show a Membership

GET /organization-memberships/:organization_membership_id

ParameterDescription
:organization_membership_idThe organization membership
StatusResponseReason
200JSON API document (type: "organization-memberships")The request was successful
404JSON API error objectOrganization membership not found, or user unauthorized to perform action

»Sample Request

$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  https://app.terraform.io/api/v2/organization-memberships/ou-kit6GaMo3zPGCzWb
$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  https://app.terraform.io/api/v2/organization-memberships/ou-kit6GaMo3zPGCzWb

»Sample Response

{
    "data": {
        "id": "ou-kit6GaMo3zPGCzWb",
        "type": "organization-memberships",
        "attributes": {
            "status": "active"
        },
        "relationships": {
            "teams": {
                "data": [
                    {
                        "id": "team-97LkM7QciNkwb2nh",
                        "type": "teams"
                    }
                ]
            },
            "user": {
                "data": {
                    "id": "user-hn6v2WK1naDpGadd",
                    "type": "users"
                }
            },
            "organization": {
                "data": {
                    "id": "hashicorp",
                    "type": "organizations"
                }
            }
        }
    }
}
{
    "data": {
        "id": "ou-kit6GaMo3zPGCzWb",
        "type": "organization-memberships",
        "attributes": {
            "status": "active"
        },
        "relationships": {
            "teams": {
                "data": [
                    {
                        "id": "team-97LkM7QciNkwb2nh",
                        "type": "teams"
                    }
                ]
            },
            "user": {
                "data": {
                    "id": "user-hn6v2WK1naDpGadd",
                    "type": "users"
                }
            },
            "organization": {
                "data": {
                    "id": "hashicorp",
                    "type": "organizations"
                }
            }
        }
    }
}

»Remove User from Organization

DELETE /organization-memberships/:organization_membership_id

ParameterDescription
:organization_membership_idThe organization membership
StatusResponseReason
204Empty bodySuccessfully removed the user from the organization
403JSON API error objectUnable to remove the user: you cannot remove yourself from organizations which you own
404JSON API error objectOrganization membership not found, or user unauthorized to perform action

»Sample Request

$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request DELETE \
  https://app.terraform.io/api/v2/organization-memberships/ou-tTJph1AQVK5ZmdND
$ curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request DELETE \
  https://app.terraform.io/api/v2/organization-memberships/ou-tTJph1AQVK5ZmdND

»Available Related Resources

The GET endpoints above can optionally return related resources, if requested with the include query parameter. The following resource types are available:

  • user - The user associated with the membership.
  • teams - Teams the user is a member of.
github logoEdit this page
  • Overview
  • Docs
  • Extend
  • Privacy
  • Security
  • Press Kit
  • Consent Manager