# Provision a Managed Organizational Unit

> **EARLY ACCESS**

> **Early access program**
>
> This is in our early access program where we closely support organizations in their usage.
>
> To have this enabled for your organization contact support@cronofy.com or your account manager.

### Description
Creates a Managed Organizational Unit, or updates it if your application has
already provisioned one with the same `organizational_unit_id`, and returns an
authorization for it.

The Managed Organizational Unit collects your customer's connections to
services such as their calendar and conferencing systems, the people you
[add as members](https://docs.cronofy.com/api-reference/managed-scheduling/managed-organizational-units/add-member/index.md),
and everyone's scheduling preferences. Your application solely controls its
membership.

The authorization has the `organizational_unit_scheduling` scope. It's
equivalent to the customer authorizing your application through
[Organization Connect](https://docs.cronofy.com/developers/temporal-grid/connectivity/organization-connect/index.md),
and its access token is
[refreshed](https://docs.cronofy.com/api-reference/authorization/organization-connect/refresh-token/index.md)
in the same way. If the authorization has been revoked, provisioning again
creates a new one.

Authentication is with your application's `client_secret`.

### URL format
```
{data_center_url}/v1/organizational_units
```

### Example Request
```http
POST /v1/organizational_units HTTP/1.1
Host: {data_center_url}
Authorization: Bearer {CLIENT_SECRET}
Content-Type: application/json; charset=utf-8

{
  "organizational_unit_id": "customer-123",
  "name": "Hill Valley Futures",
  "default_locale": "en",
  "default_tzid": "America/Chicago",
  "callback_url": "https://example.com/cronofy/notifications"
}
```

### Example Response
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "organizational_unit": {
    "sub": "org_16c99459e89a32a08cdb6b2a",
    "organizational_unit_id": "customer-123",
    "name": "Hill Valley Futures",
    "default_locale": "en",
    "default_tzid": "America/Chicago",
    "callback_url": "https://example.com/cronofy/notifications"
  },
  "authorization": {
    "access_token": "{ACCESS_TOKEN}",
    "token_type": "bearer",
    "expires_in": 3600,
    "refresh_token": "{REFRESH_TOKEN}",
    "scope": "organizational_unit_scheduling",
    "sub": "org_16c99459e89a32a08cdb6b2a"
  }
}
```

`200 OK` is returned whether the Managed Organizational Unit was created or
already existed.

### Request Parameters
##### `data_center_url` *(required)*

The URL for the data center you want to communicate with. Possible choices are:

- `api-au.cronofy.com` - Australia
- `api-ca.cronofy.com` - Canada
- `api-de.cronofy.com` - Germany
- `api-sg.cronofy.com` - Singapore
- `api-uk.cronofy.com` - United Kingdom
- `api.cronofy.com` - United States

Find out more about [Cronofy's data centers](https://docs.cronofy.com/developers/data-centers/index.md).
##### `organizational_unit_id` *(required)*

Your application's identifier for the Managed Organizational Unit, such as the
ID of the customer in your system [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

It's unique among the Managed Organizational Units your application manages
in the data center. Provisioning again with the same `organizational_unit_id`
updates the existing Managed Organizational Unit.

##### `name` *(required)*

The name of the Managed Organizational Unit, typically your customer's name
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

Set to the value sent on every call.

##### `default_locale` *(optional)*

The default locale for the Managed Organizational Unit, such as `en` or `fr`
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

Defaults to `en` when the Managed Organizational Unit is created. Left
unchanged when omitted.

Supported locales:

- `ar` Arabic

- `cs` Czech

- `cy` Welsh

- `de` German

- `en` US English (default)

- `es` Spanish

- `fr` French

- `fr-CA` Canadian French

- `he` Hebrew

- `it` Italian

- `ja` Japanese

- `nl` Dutch

- `pl` Polish

- `pt-BR` Brazilian Portuguese

- `ru` Russian

- `sv` Swedish

- `tr` Turkish

- `zh-CN` Simplified Chinese

##### `default_tzid` *(optional)*

The default time zone for the Managed Organizational Unit, as an identifier
from the [IANA Time Zone Database](https://www.iana.org/time-zones) such as
`America/Chicago` [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

Left unchanged when omitted. If it has never been set, the data center's
default time zone is used.

##### `callback_url` *(optional)*

The URL Cronofy sends webhooks to for the Managed Organizational Unit, such as
those about its members and
[Scheduling Requests](https://docs.cronofy.com/api-reference/managed-scheduling/scheduling-requests/webhooks/index.md)
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

It must be an `http` or `https` URL that's reachable from the internet. Left
unchanged when omitted. Pass `null` to stop sending webhooks.

### Response Parameters
##### `organizational_unit.sub`

Cronofy's identifier for the Managed Organizational Unit
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `organizational_unit.organizational_unit_id`

Your application's identifier for the Managed Organizational Unit
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `organizational_unit.name`

The name of the Managed Organizational Unit
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `organizational_unit.default_locale`

The default locale [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `organizational_unit.default_tzid`

The default time zone identifier [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `organizational_unit.callback_url`

The URL webhooks are sent to, or `null` if none
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `authorization.access_token`

The access token for calling the API on behalf of the Managed Organizational
Unit [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `authorization.token_type`

Always `bearer` [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `authorization.expires_in`

The number of seconds until the access token expires
[`Integer`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `authorization.refresh_token`

The refresh token for getting a new access token with
[Refresh an Access Token](https://docs.cronofy.com/api-reference/authorization/organization-connect/refresh-token/index.md)
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

Provisioning again also returns a valid access token.

##### `authorization.scope`

The scopes granted, separated by spaces. Includes
`organizational_unit_scheduling` [`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

##### `authorization.sub`

Cronofy's identifier for the Managed Organizational Unit
[`String`](https://docs.cronofy.com/api-reference/fundamentals/data-types/index.md).

### Error responses
##### 401 Unauthorized

The request was refused as the `client_secret` wasn't recognized.

##### 402 Payment Required

The request was refused as your plan doesn't include Managed Organizational
Units.

##### 403 Forbidden

The request was refused as it was made by an
[Internal Application](https://docs.cronofy.com/api-reference/application-management/internal-applications/index.md).

##### 422 Unprocessable

The request was unable to be processed due to it containing invalid
parameters.

The response contains a JSON object with one or more errors for the invalid
parameters. For example, omitting the required `name` parameter returns:

```json
{
  "errors": {
    "name": [
      {
        "key": "errors.required",
        "description": "required"
      }
    ]
  }
}
```

The `key` is intended for programmatic use, and the `description` is a
human-readable equivalent.



---
[Read in HTML](https://docs.cronofy.com/api-reference/managed-scheduling/managed-organizational-units/provision/)