Skip to main content

Purpose API

Usageโ€‹

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.purpose.createPurpose(...)

Tree-shakeable importโ€‹

import { getClient, authorize } from '@epilot/sdk/purpose'

const purposeClient = getClient()
authorize(purposeClient, () => '<token>')
const { data } = await purposeClient.createPurpose(...)

Operationsโ€‹

Purpose

Schemas

createPurposeโ€‹

Create Purpose

POST /v1/purpose

const { data } = await client.createPurpose(
null,
{
name: 'Electricity Contract'
},
)
Response
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Electricity Contract",
"created_at": "1970-01-01T00:00:00.000Z",
"updated_at": "1970-01-01T00:00:00.000Z"
}

searchPurposesโ€‹

Search Purposes

GET /v1/purpose:search

const { data } = await client.searchPurposes({
query: 'example',
size: 1,
})
Response
{
"results": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Electricity Contract",
"created_at": "1970-01-01T00:00:00.000Z",
"updated_at": "1970-01-01T00:00:00.000Z"
}
]
}

batchGetPurposesโ€‹

Batch Get Purposes

POST /v1/purpose:batchGet

const { data } = await client.batchGetPurposes(
null,
{
purposeIds: ['123e4567-e89b-12d3-a456-426614174000']
},
)
Response
{
"results": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Electricity Contract",
"created_at": "1970-01-01T00:00:00.000Z",
"updated_at": "1970-01-01T00:00:00.000Z"
}
],
"hits": 0
}

getPurposeโ€‹

Get Purpose

GET /v1/purpose/{purposeId}

const { data } = await client.getPurpose({
purposeId: 'example',
})
Response
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Electricity Contract",
"created_at": "1970-01-01T00:00:00.000Z",
"updated_at": "1970-01-01T00:00:00.000Z"
}

updatePurposeโ€‹

Update Purpose

PUT /v1/purpose/{purposeId}

const { data } = await client.updatePurpose(
{
purposeId: 'example',
},
{
name: 'string'
},
)
Response
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Electricity Contract",
"created_at": "1970-01-01T00:00:00.000Z",
"updated_at": "1970-01-01T00:00:00.000Z"
}

deletePurposeโ€‹

Delete Purpose

DELETE /v1/purpose/{purposeId}

const { data } = await client.deletePurpose({
purposeId: 'example',
})
Response
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Electricity Contract",
"created_at": "1970-01-01T00:00:00.000Z",
"updated_at": "1970-01-01T00:00:00.000Z"
}

Schemasโ€‹

Purposeโ€‹

A purpose used to tag and organize entities

type Purpose = {
id: string // uuid
name: string
created_at?: string // date-time
updated_at?: string // date-time
}

CreatePurposeInputโ€‹

Input for creating a new purpose

type CreatePurposeInput = {
name: string
}

UpdatePurposeInputโ€‹

Input for updating an existing purpose

type UpdatePurposeInput = {
name?: string
}

BatchGetPurposesInputโ€‹

Input for batch getting purposes

type BatchGetPurposesInput = {
purposeIds: string[]
}

Errorโ€‹

type Error = {
status?: number
error?: string
}