# Rest API

### Requirements <a href="#requirements" id="requirements"></a>

Our api needs the following requirements

```python
myAuth : Unique and non-transferable token for authenticate requests

myCorporateToken : Unique and non-transferable token to make requests to our resources

HOST : Will be provided by Imbee

All requests must use the header "Content-Type" with value "application/json"
```

All requests to our API have the same response format, which is composed of the following properties:

time: time spent generating a response.

code: The generic codes are 1 if an error was detected while processing your request, or 0 if your request could be processed. There may be more error codes that will be detailed in each web services if they exist.

message: descriptive message of the webservice, it is not relevant.

body: The answer itself of the request made.

```python
{
    "time": 0.00019,
    "code": 0,
    "message": "Ok",
    "body": {
        "data0": "value0",
        "data1": "value1"
    }
}
```

### Generate a Access Token <a href="#generate-a-access-token" id="generate-a-access-token"></a>

Create a new web access token from a unique identifier

params:

```python
virutal_user: can not be null or empty

bot_idsha: unique and non-transferable bot identifier

mail: address to send a mail with the access token (optional*)

celullar: celullar to send a sms with the access token (optional*)

max_retries: amount of retries that a user can use the access token (optional, if not specified, the default limit will be set)

date_limit: date that a access token will be valid, date format YYYY-MM-DD (optional, if not specified, the default limit will be set)
```

Notes:

```
mail or celullar can be optional, but not both at the same time
```

Request:

```python
curl --request POST --url https://HOST/token/new --header 'Authorization: myAuth' --header 'Content-Type: application/json' --header 'X-WOOS-KEY: myCorporateToken' --data '{"virtual_user":"user_identifier_sha", "bot_idsha":"bot_identifier", "mail":"user_email", "celullar":"user_phone", "max_retries": 10, "date_limit": "2018-12-31"}'
```

If no date\_limit or max\_retries

Response:

```python
{
    "time": 0.00019,
    "code": 0,
    "message": "Ok",
    "body": {
        "url": "url_with_token",
        "user_idsha": "idsha_value",
        "date_limit": "2000-01-01",
        "max_retries": 10,
        "previously_created": false
    }
}
```

### Create a External User <a href="#create-a-external-user" id="create-a-external-user"></a>

Creating a new user from a unique identifier

Request:

```python
curl --request POST --url https://HOST/third_parties/user/new --header 'Authorization: myAuth' --header 'Content-Type: application/json' --header 'X-WOOS-KEY: myCorporateToken' --data '{"uniqueIdSha":"user_identifier_sha", "platform": "platformValue","deviceName": "deviceNameValue","hardwareId":"hardwareIdValue","osVersion":"osVersionValue"}'
```

Response:

```python
{
    "time": 0.01809,
    "code": 0,
    "message": "Ok",
    "body": {
        "virtualUser": "idShaValue_user1",
        "pass": "pass_user1",
        "apikey": "apikey_user1",
        "previously_registered": false
    }
}
```

### Create a Chat between users <a href="#create-a-chat-between-users" id="create-a-chat-between-users"></a>

Request:

```python
curl --request POST --url http://HOST/chat/create --header 'Authorization: myAuth' --header 'Content-Type: application/json' --header 'X-WOOS-KEY: apikey_user1' --data '{"type":"chat", "contacts":[{"idsha":"idShaValue_user2"}]}'
```

Response:

```python
{
  "body": {
    "contacts": [
    {
      "idsha": "idShaValue_user1",
      "isadmin": 1
    },
    {
      "idsha": "idShaValue_user2",
      "isadmin": 0
    }
    ],
    "conversationId": "conversation_identifier",
    "previously_created": false
  },
  "code": 0,
  "message": "Ok.",
  "time": 0
}
```


---

# 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.imbee.me/imbee-docs/rest-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.
