# Database models

**applications**\
Represent an application in the database

```javascript
{
  //PK
  "company_id": uuid;
  "id": uuid;

  "identity": ApplicationIdentity;
  "api": ApplicationApi;
  "access": ApplicationAccess;
  "display": ApplicationDisplay;
  "publication": ApplicationPublication;
  "stats": ApplicationStatistics;
}

type ApplicationIdentity = {
  name: string;
  iconUrl: string;
  description: string;
  website: string;
  categories: string[];
  compatibility: "twake"[];
};

type ApplicationPublication = {
  published: boolean;
};

type ApplicationStatistics = {
  createdAt: number;
  updatedAt: number;
  version: number;
};

type ApplicationApi = {
  hooksUrl: string;
  allowedIps: string;
  privateKey: string;
};

type ApplicationAccess = {
  privileges: string[];
  capabilities: string[];
  hooks: string[];
};

type ApplicationDisplay = {
  twake: {
    "version": 1,

		"files" : {
	    "preview": {
				"url": "", //Url to preview file (full screen or inline)
				"inline": true,
				"main_ext": ["docx", "xlsx"], //Main extensions app can read
				"other_ext": ["txt", "html"] //Secondary extensions app can read
			},
			"actions": [ //List of action that can apply on a file
				{
					"name": "string",
					"id": "string"
				}
			]
	  },

		//Chat plugin
	  "chat": {
	    "input": {
				"icon": "", //If defined replace original icon url of your app 
	      "type": "file" | "call" //To add in existing apps folder / default icon
	    },
	    "commands": [
				{
					"command": "mycommand", // my_app mycommand
	        "description": "fdsqfds"
				}
			],
			"actions": [ //List of action that can apply on a message
				{
					"name": "string",
					"id": "string"
				}
			]
	  },

		//Allow app to appear as a bot user in direct chat
    "direct": {
			"name": "My app Bot",
      "icon": "", //If defined replace original icon url of your app
    },

		//Display app as a standalone application in a tab
	  "tab": {
	    "url": ""
	  },

		//Display app as a standalone application on the left bar
	  "standalone": {
	    "url": ""
	  },

    //Define where the app can be configured from
	  "configuration": ["global", "channel"]
  };
};
```

**company\_application**\
Represent an application in a company

```javascript
{
	"company_id": uuid;
	"application_id": uuid;
	"id": uuid;
	
	"created_at": number;
	"created_by": string; //Will be the default delegated user when doing actions on Twake
}
```


---

# 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://doc.twake.app/internal-documentation/backend-services/applications/database-models.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.
