# Instance API

## Enabling the Instance API

To enable the Instance API, you will need to provide an authentication token via an environment variable:

```bash
UI_BAKERY_INSTANCE_API_TOKEN=YOUR_TOKEN
```

## Making Requests to the UI Bakery SCIM API

The UI Bakery Instance API available on the following URL, where `UI_BAKERY_INSTANCE` is your domain.

```
http(s)://UI_BAKERY_INSTANCE/api/instance/**
```

To authenticate your requests, include the `Authorization: Bearer TOKEN` header with the value provided in the `UI_BAKERY_INSTANCE_API_TOKEN` environment variable

## Reference

### App methods:

### Pull branch in app

<mark style="color:green;">`POST`</mark> `https://UI_BAKERY_INSTANCE/api/instance/app/{app_id}/pull`

Pull latest commits for specified app/branch

#### Path Parameters

| Name                                    | Type   | Description      |
| --------------------------------------- | ------ | ---------------- |
| appId<mark style="color:red;">\*</mark> | String | UI Bakery app id |

#### Query Parameters

| Name                                          | Type   | Description |
| --------------------------------------------- | ------ | ----------- |
| uib\_branch<mark style="color:red;">\*</mark> | String | Branch name |

{% tabs %}
{% tab title="200: OK Returns the last pulled commit" %}

```
{
    "status": "OK",
    "message": "Branch pulled",
    "result": {
        "lastCommit": {
            "hash": "359ad61432a481497b96c3c8hb4ad751f68bfd19",
            "message": "feat(home): update user table"
        }
    }
}
```

{% endtab %}
{% endtabs %}

### Relese app

<mark style="color:green;">`POST`</mark> `https://UI_BAKERY_INSTANCE/api/instance/app/{app_id}/release`

Releasing the app to specified environments: If both "prod" and "staging" are false, the release becomes a "Draft"; if no "branch" parameter is provided, the main branch is used by default.

If version is not specified, the last valid version will be patched.

#### Path Parameters

| Name                                    | Type   | Description      |
| --------------------------------------- | ------ | ---------------- |
| appId<mark style="color:red;">\*</mark> | String | UI Bakery app id |

#### Request Body

| Name                                      | Type    | Description                                       |
| ----------------------------------------- | ------- | ------------------------------------------------- |
| version                                   | String  | Release version                                   |
| description                               | String  | Release description                               |
| prod<mark style="color:red;">\*</mark>    | Boolean | Should release be created for Prod environment    |
| staging<mark style="color:red;">\*</mark> | Boolean | Should release be created for Staging environment |
| branch                                    | String  | From what branch release should be created        |

{% tabs %}
{% tab title="200: OK Returns the last 10 releases" %}

```
{
    "status": "CREATED",
    "message": "App released",
    "result": {
        "releases": [
            {
                "id": "4UMYn3VOnm",
                "version": "0.11.1",
                "description": "",
                "createdBy": "Organization Admin",
                "createdAt": "2024-01-01T15:07:50.000+00:00",
                "prod": true,
                "staging": false,
                "dev": null,
                "branch": "main",
                "commitHash": "363ae61431a481497v96c3c87b4ad751f68bfd19",
                "commitMessage": "Update main.yml"
          }
        ]
}     
```

{% endtab %}
{% endtabs %}

## Example integrations

{% content-ref url="/pages/JpIHy3U6m34WEKf8fuyR" %}
[Automate GitHub releases](/on-premise/git-source-control/automate-github-releases.md)
{% endcontent-ref %}

{% content-ref url="/pages/RomNUvcvOcuBRwt7gUDC" %}
[Automate GitLab releases](/on-premise/git-source-control/automate-gitlab-releases.md)
{% endcontent-ref %}

{% content-ref url="/pages/9Y31751fQ6wE0G8Qwdoq" %}
[Automate Bitbucket releases](/on-premise/git-source-control/automate-bitbucket-releases.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/on-premise/on-premise-features/instance-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
