Skip to content

mixpanel_user_project_role (Resource)

Grants a user a role on a Mixpanel project — assigns permissions that determine what the user can do within that project (view reports, edit data, manage settings, etc.).

Example Usage

# Grant a user a role on a project. Requires an organization-admin service
# account. `key` MUST be the user's email: Read confirms the grant by finding
# that email in the org users list (GET /organizations/{organization_id}/users/).
resource "mixpanel_user_project_role" "alice_analyst" {
  organization_id = 7654321
  key             = "alice@example.com"
  payload         = jsonencode({ users = ["alice@example.com"], projects = [1234567], role = "analyst" })
}

Schema

Required

  • key (String) Read-selection key for this association (the user's email address, which must appear in the org users list (GET /organizations/{organization_id}/users/); Read confirms the grant by finding this email in that list). Changing it forces a new association.
  • payload (String) jsonencode'd request body for the create/delete verbs (the API bodies are untyped). Changing it forces a new association.

Optional

  • organization_id (String) Organization ID. Defaults to the provider organization.

Read-Only

  • id (String) Synthetic composite identity: ":".

Import

Import using the composite identifier ORGANIZATION_ID:USER_EMAIL:

import {
  to = mixpanel_user_project_role.alice_analyst
  id = "7654321:alice@example.com"
}

Numeric ids in the payload

The add-users-to-projects endpoint requires project/user ids to be JSON numbers; string ids cause a server 500. Because HCL string interpolation ("${var.project_id}") renders ids as strings inside jsonencode, the provider automatically coerces every id field in the payload whose value is a canonical decimal string ("12345") into a JSON number before sending it. Non-numeric ids and every other field are passed through verbatim:

resource "mixpanel_user_project_role" "alice_analyst" {
  key = "alice@example.com"
  payload = jsonencode({
    projects = [
      {
        id    = var.project_id # number or numeric string — both reach the wire as a number
        users = [{ email = "alice@example.com", role = "analyst" }]
      }
    ]
  })
}