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

# Organizations

> List, get, create, update, and delete organizations using the Arize Go SDK.

<Note>
  The `organizations` client methods are currently in **ALPHA**. The API may change without notice. A one-time warning is emitted on first use.
</Note>

Organizations group spaces and members under a billing account. The `Get`, `Update`, `Delete`, `AddUser`, and `RemoveUser` methods accept either an organization name or an ID — the SDK resolves names to IDs on your behalf.

## List Organizations

`List` returns a paginated list of organizations.

**Signature:**

```go theme={null}
func (c *Client) List(ctx context.Context, req ListRequest) (*OrganizationList, error)
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    resp, err := client.Organizations.List(context.Background(), organizations.ListRequest{
        Limit: 25,
    })
    if err != nil {
        var unauthorized *arize.UnauthorizedError
        if errors.As(err, &unauthorized) {
            log.Fatalf("unauthorized: %v", unauthorized)
        }
        log.Fatal(err)
    }

    for _, org := range resp.Organizations {
        fmt.Printf("%s: %s\n", org.Id, org.Name)
    }
}
```

## Get an Organization

`Get` returns a single organization, resolving by name or ID.

**Signature:**

```go theme={null}
func (c *Client) Get(ctx context.Context, req GetRequest) (*Organization, error)
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    org, err := client.Organizations.Get(
        context.Background(),
        organizations.GetRequest{Organization: "your-org-name-or-id"},
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Fatalf("organization not found: %v", notFound)
        }
        log.Fatal(err)
    }

    fmt.Printf("org %s: %s\n", org.Id, org.Name)
}
```

## Create an Organization

`Create` issues a `POST` to create a new organization and returns the created organization.

**Signature:**

```go theme={null}
func (c *Client) Create(
    ctx context.Context,
    req CreateRequest,
) (*Organization, error)
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    org, err := client.Organizations.Create(
        context.Background(),
        organizations.CreateRequest{
            Name: "your-new-org",
        },
    )
    if err != nil {
        var conflict *arize.ConflictError
        if errors.As(err, &conflict) {
            log.Fatalf("organization already exists: %v", conflict)
        }
        log.Fatal(err)
    }

    fmt.Printf("created org %s\n", org.Id)
}
```

## Update an Organization

`Update` modifies an existing organization, resolving the target by name or ID, and returns the updated organization. `Name` and `Description` are pointers — `nil` preserves the existing value, a pointer to an empty string clears the field.

**Signature:**

```go theme={null}
func (c *Client) Update(
    ctx context.Context,
    req UpdateRequest,
) (*Organization, error)
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    newName := "renamed-org"
    org, err := client.Organizations.Update(
        context.Background(),
        organizations.UpdateRequest{
            Organization: "your-org-name-or-id",
            Name:         &newName,
        },
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Fatalf("organization not found: %v", notFound)
        }
        log.Fatal(err)
    }

    fmt.Printf("updated org %s: %s\n", org.Id, org.Name)
}
```

## Delete an Organization

`Delete` irreversibly removes an organization and cascades to all child resources (spaces, projects, API keys, datasets, monitors, etc.). It returns only an error.

**Signature:**

```go theme={null}
func (c *Client) Delete(ctx context.Context, req DeleteRequest) error
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    err = client.Organizations.Delete(
        context.Background(),
        organizations.DeleteRequest{Organization: "your-org-name-or-id"},
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Printf("no organization to remove: %v", notFound)
            return
        }
        log.Fatal(err)
    }
}
```

## Add a User to an Organization

`AddUser` adds a user to an organization, or upserts their role if they are already a member. Pass a `PredefinedOrgRole` built from one of the `OrganizationRole*` constants; custom role assignments are not yet supported for organizations.

**Signature:**

```go theme={null}
func (c *Client) AddUser(
    ctx context.Context,
    req AddUserRequest,
) (*OrganizationMembership, error)
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    membership, err := client.Organizations.AddUser(
        context.Background(),
        organizations.AddUserRequest{
            Organization: "your-org-name-or-id",
            UserID:       "your-user-id",
            Role: organizations.PredefinedOrgRole{
                Name: organizations.OrganizationRoleMember,
            },
        },
    )
    if err != nil {
        var forbidden *arize.ForbiddenError
        if errors.As(err, &forbidden) {
            log.Fatalf("forbidden: %v", forbidden)
        }
        log.Fatal(err)
    }

    fmt.Printf("user %s added to org\n", membership.UserId)
}
```

## Remove a User from an Organization

`RemoveUser` removes a user from an organization. Membership removal cascades to all child spaces.

**Signature:**

```go theme={null}
func (c *Client) RemoveUser(ctx context.Context, req RemoveUserRequest) error
```

**Usage Example:**

```go theme={null}
package main

import (
    "context"
    "errors"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/organizations"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    err = client.Organizations.RemoveUser(
        context.Background(),
        organizations.RemoveUserRequest{
            Organization: "your-org-name-or-id",
            UserID:       "your-user-id",
        },
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Printf("user not in organization: %v", notFound)
            return
        }
        log.Fatal(err)
    }
}
```
