# Endpoints

Restful APIs are ready to use to interact with DocKing 😎

### \[GET] api/v1/document-templates

Get a list of templates

Request params:

* limit: default `20`
* page: default `1`

Response:

```javascript
{
    data: DocumentTemplate[],
    ...paginationInfo
}
```

### \[GET] api/v1/document-templates/{uuid}

Get a single template detail.

Response:

```javascript
{
    data: DocumentTemplate,
}
```

### \[POST] api/v1/document-templates

Create a new template.

Body:

```json
{
    "title": "title here",
    "category": "category here",
    "key": "unique identifier key here"
}
```

Response: 201 on OK, 422 on Validation Error

```json
{
    "uuid": "...",
    "created": true
}
```

### \[PUT] api/v1/document-templates/{uuid}

Update an existing template.

Body:

```json
{
    "title": "title here",
    "category": "category here",
    "key": "unique identifier key here",
    "template": "html template here",
    "default_variables": { object of default variable },
    "metadata": { obj of metadata }
}
```

Response: 200 on OK, 422 on Validation Error

```json
{
    "uuid": "...",
    "updated": true
}
```

### \[DELETE] api/v1/document-templates/{uuid}

Delete a single template.

Response: 200 on OK

```json
{
    "uuid": "...",
    "deleted": true
}
```

### \[POST] api/v1/document-templates/{uuid}/pdfs

Render a template with the given data and returns the PDF file URL.

* Body
  * `variables` (JSON object or array)
  * `metadata` (JSON object)
* Response
  * OK: 200 with URL.
  * ERROR:&#x20;
    * 400 with message or outcome.
    * 422 for validation errors.

### \[POST] api/v1/document-templates/{uuid}/pdfs-async

Asynchronously render a new template.

* Body
  * `variables` (JSON object or array)
  * `metadata` (JSON object)
  * `webhook_url` (REQUIRED), for render result notification
* Response
  * OK: 200 with the outcome.
  * ERROR:
    * 422: for validation errors.

### \[GET] api/v1/document-files

Get a list of document files

Request params:

* limit: default `20`
* page: default `1`

Response:

```javascript
{
    data: File[],
    ...paginationInfo
}
```

### \[POST] api/v1/document-files/{uuid}

Returns the single rendered pdf file
