# Apty OpenAPI
## Prerequisites
Following details are required before using the Apty OpenAPI.
1. API KEY - `Can be found under Open API tab under manage settings page`
2. Tenant key - `Apty will provide Tenant key`
3. Tenant Id - `Apty will provide Tenant Id`
4. Application Id - `Apty will provide Application Id`
Every request should have following headers
```json=
Content-Type: application/json
api_key: XXXXXXXXXXXXXXXXX
```
## Upload image API
We suupport only `jpeg` and `jpg` image formats and image cannot be more than `0.5MB` and you can upload only one image at a time
### Method
```POST```
### Headers
```json=
Content-Type: multipart/form-data
api_key: XXXXXXXXXXXXXXXXX
```
### Url
```js
https://{host}/open-api/images/tenant/{tenantKey}/appId/{appId}
```
### Response
```json=
{
imagePath: "XXXXXXX"
}
```
## Create announcement API
### Method
```POST```
### Headers
```json=
Content-Type: application/json
api_key: XXXXXXXXXXXXXXXXX
```
### Url
```js
https://{host}/open-api/announcement/tenant/{tenantKey}/appId/{appId}
```
### request body sample
```json=
{
formId: string; // page identifier
name: string; // name of the announcement
content: string; // we support both html and plain text
acceptLabel: string; // announcement accept button text
cancelLabel: string; // announcement cancel button text
}
```
### Response
Success ✅
```json=
{
"announcementId": "XXXXXX"
}
```
failure ❌
```json=
{
"message": "XXXXXXXXXX"
}
```
### Full http body
| Key | Value | Description |
|---------------------|---------|--------------------------------------------------------------------------------------------------------------------------|
| name | string | Name of the announcement |
| content | string | Content of the announcement. we support both raw html and text |
| acceptLabel | string | Accept button text |
| cancelLabel | string | Cancel button text |
| checkBoxLabel | string | Text for Anouncement checkbox |
| formId | number | Page identifier |
| hasImage | boolean | enables image in Announcemnt |
| imageUrl | string | Url points to announcement Image |
| imagePosition | string | Possible Values (`top,right,bottom,left`) |
| imageSize | string | Possible Values (`one-third,half,two-third,full`) |
| scheduleEnabled | boolean | Show announcement between `Dates` |
| toDate | string | format yyyy-dd-MM HH:mm:ss |
| fromDate | string | format yyyy-dd-MM HH:mm:ss |
| timeZone | string | TimeZone to show announcement |
| announcementType | number | Possible Values (`0,1,2,3`). `0 - Workflow 1- Url 2- Video 3 - Ok` |
| customContentId | number | Content attached to Announcement |
| flowId | number | Workflow to launch |
| stepId | number | Step to launch |
| theme | string | name of the theme |
| fitBalloonToContent | boolean | Fits the balloon content |
| position | string | Possible values (`TOP-LEFT,TOP-MIDDLE,TOP-RIGHT,LEFT-MIDDLE,CENTER,RIGHT-MIDDLE,BOTTOM-LEFT,BOTTOM-MIDDLE,BOTTOM-RIGHT`) |
| conditions | array | Refer to announcement condition section |
| isMandatory | boolean | Sets announcement as Mandatory |
| showCancelButton | boolean | Show cancel button for announcement |
| CTA | array | Refer to CTA section |
| themeId | number | Applies theme to Announcement |
| contentData | object | Refer to `Conten Data section ` |
| createContent | boolean | Check if we would like to create content |
### Announcement Conditions
| Key | Value | Description |
|--------|--------|--------------------------------|
| type | number | Possible values - (`3`) |
| script | string | Custom script for announcement |
### Conten Data
| Key | Value | Description |
|------|--------|------------------------------------------------|
| type | number | Possible Values - (`0,1,2`) `URL - 0, Video - 1, Image - 2` |
| name | string | Name of the Content |
| url | string | Url of the content |
| | | |
### CTA
Announcement CTA input details
| Key | Value | Description |
|--------------------|---------|------------------------------------------------------|
| actionType | string | Possible Values (`Okay,Cross,External`) |
| label | string | CTA button text |
| isDismiss | boolean | Never show announcement when clicked button |
| isHide | boolean | Hide Announcement when clicked button |
| buttonStyle | object | Refer to `CTA Button Style` section |
| tool | object | Refer to `CTA Tool` section |
| isAcceptanceAction | boolean | launch action on announcement and consider as accept |
### CTA Button Style
| Key | Value | Description |
|-----------|--------|-------------------------------------------------------------------|
| className | string | CTA Button type. Possible value (`primary, secondary`) |
| alignment | string | CTA Button alignment. Possible Values (`left,center,right`) |
### CTA Tool
| Key | Value | Description |
|----------|--------|-----------------------------------------------------------------|
| toolType | number | Possible Values (`0,1,2,3`). `Workflow - 0, Url - 1, Video - 2, Ok - 3 ` |
| toolId | number | either flowId or content Id based on toolType value |
| stepId | number | Step to launch |
## Download Self-Hosted Content API
This API will download the content published from Studio or Admin as zip file. The content can be downloaded and hosted accordingly.
### Method
```GET```
### Headers
```json=
Content-Type: application/zip
api_key: XXXXXXXXXXXXXXXXX // Refer prerequisites section
```
### Url
```js
https://{host}/assist/api/downloads/{tenantId}/content
```
### Response
Success ✅
A file named ```content.zip``` will get downloaded
```json=
{
"status": 200
}
```
## Download Self-Hosted Fonts API
This API will download the fonts as zip file. The fonts can be downloaded and hosted accordingly.
### Method
```GET```
### Headers
```json=
Content-Type: application/zip
api_key: XXXXXXXXXXXXXXXXX // Refer prerequisites
```
### Url
```js
https://{host}/assist/api/downloads/{tenantId}/fonts
```
### Response
Success ✅
A file named ```fonts.zip``` will get downloaded.
```json=
{
"status": 200
}
```