> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/graphql-api/mutations/registertenant.md).

# Register Tenant

registerTenant Mutation

Registers a new tenant (organization) in the pyck system along with an initial admin user. This mutation is unauthenticated and can be called without an Authorization header, making it suitable for self-service tenant provisioning.

## Arguments

| Name    | Type                   | Description                                          |
| ------- | ---------------------- | ---------------------------------------------------- |
| `input` | `RegisterTenantInput!` | Input data for registering the tenant and admin user |

## Return Type

`RegisterTenantResponse!` - Contains the success status and details of the registration operation.

## Input Fields

`RegisterTenantInput`:

| Field            | Type      | Description                                       |
| ---------------- | --------- | ------------------------------------------------- |
| `name`           | `String!` | Required tenant name                              |
| `adminUsername`  | `String!` | Required username for the initial admin user      |
| `adminEmail`     | `String!` | Required email address for the initial admin user |
| `adminFirstName` | `String!` | Required first name of the initial admin user     |
| `adminLastName`  | `String!` | Required last name of the initial admin user      |
| `adminPassword`  | `String!` | Required password for the initial admin user      |

## Usage Example

```graphql
mutation {
  registerTenant(
    input: {
      name: "Warehouse North",
      adminUsername: "admin",
      adminEmail: "admin@warehouse-north.com",
      adminFirstName: "Jane",
      adminLastName: "Doe",
      adminPassword: "securePassword123!"
    }
  ) {
    success
  }
}
```

## JavaScript Example

```javascript
const registerTenantMutation = `
  mutation RegisterTenant($input: RegisterTenantInput!) {
    registerTenant(input: $input) {
      success
    }
  }
`;

const variables = {
  input: {
    name: "Warehouse North",
    adminUsername: "admin",
    adminEmail: "admin@warehouse-north.com",
    adminFirstName: "Jane",
    adminLastName: "Doe",
    adminPassword: "securePassword123!"
  }
};

// Using fetch or your preferred GraphQL client
const response = await fetch('/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query: registerTenantMutation,
    variables: variables
  })
});

const result = await response.json();
console.log('Tenant registration result:', result.data.registerTenant);
```

## Current Behavior: Email Alias Handling

When registering multiple tenants, the system allows re-use of the same admin email address. However, the resulting tenant-specific emails are isolated:

**Example scenario:**

1. Register tenant 1 with `user@example.com`
   * Creates primary email: `user@tenant1.example.com`
   * Adds alias: `user@example.com`
2. Register tenant 2 with `user@example.com`
   * Creates primary email: `user@tenant2.example.com`
   * Adds alias: `user@example.com`

**Important notes:**

* Each tenant gets its own tenant-specific primary email (e.g., `user@tenant1.example.com`)
* The original email (`user@example.com`) is added as an alias to both accounts
* Cross-tenant authorization is not supported: `user@tenant2.example.com` cannot access tenant 1 resources and vice versa
* Each tenant registration creates a separate, isolated user account

**Recommendation:** Use unique email addresses for each tenant registration to avoid confusion and ensure clear account separation.

## Notes

* This mutation does not require authentication
* The admin user will have full administrative privileges within the new tenant
* Password requirements may apply based on system security policies
* Tenant names should be unique within the system
* This endpoint is not subject to standard tenant isolation rules


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pyck.cloud/graphql-api/mutations/registertenant.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
