# API para integrações

O Tray CLI também expõe uma API para que você possa usar/integrar os comandos do CLI em outra ferramenta. Com exceção dos comandos **`open`** e **`watch`**, todos os outros comandos estão disponíveis nessa API.

Todos os métodos dessa API retornam uma `Promise`. Você deverá observá-la para detectar quando ela foi resolvida ou rejeitada. Como algumas operações demoram a serem executadas, recomendamos sempre executá-las de modo assíncrono.

Veja o exemplo abaixo de um uso simples para gerar a configuração do tema

```javascript
import Tray from '@tray-tecnologia/cli';

const api = new Tray({
    token: 'SEU-TOKEN-AQUI',
    themeId: 1, // Id do meu tema
    debug: false,
});

api.configure()
    .then((success) => console.log(success))
    .catch((error) => console.error(error));
```

Para saber mais, acesse o repositório do projeto clicando [aqui](https://github.com/tray-tecnologia/tray-cli).&#x20;

{% hint style="warning" %}
**Atenção!**

A nova versão do Tray CLI suporta somente ESM. **CommonJS não é suportado**. Se desejar usar esse pacote atualize seu código para usar ESM.
{% endhint %}


---

# 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://partners.tray.com.br/themes/tray-cli/api-para-integracoes.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.
