Skip to main content

Target API

Usageโ€‹

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.target.createTarget(...)

Tree-shakeable importโ€‹

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

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

Operationsโ€‹

Target

Schemas

createTargetโ€‹

Create a new target entity

POST /v1/target

const { data } = await client.createTarget(
null,
{
_schema: 'target',
name: 'string',
description: 'string',
entity_schema: 'string',
entity_filters: {
filter: {
items: [
{
key: 'string',
operator: 'string',
value: 'string'
}
],
combination: 'string'
}
},
_tags: ['string'],
_purpose: ['string'],
_files: {
$relation: [
{
entity_id: '123e4567-e89b-12d3-a456-426614174000',
_tags: ['string']
}
]
},
_manifest: ['123e4567-e89b-12d3-a456-426614174000'],
__additional: {}
},
)
Response
{
"_id": "123e4567-e89b-12d3-a456-426614174000",
"_schema": "target",
"_org": "string",
"_tags": ["string"],
"_files": {
"$relation": [
{
"entity_id": "123e4567-e89b-12d3-a456-426614174000",
"_tags": ["string"]
}
]
},
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_title": "string",
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"description": "string",
"entity_schema": "string",
"entity_filters": {
"filter": {
"items": [
{
"key": "string",
"operator": "string",
"value": "string"
}
],
"combination": "string"
}
},
"_purpose": ["string"],
"_manifest": ["123e4567-e89b-12d3-a456-426614174000"],
"__additional": {}
}

getTargetโ€‹

Read a specific target entity by a given id

GET /v1/target/{targetId}

const { data } = await client.getTarget({
targetId: 'example',
hydrate: true,
strict: true,
})
Response
{
"_id": "123e4567-e89b-12d3-a456-426614174000",
"_schema": "target",
"_org": "string",
"_tags": ["string"],
"_files": {
"$relation": [
{
"entity_id": "123e4567-e89b-12d3-a456-426614174000",
"_tags": ["string"]
}
]
},
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_title": "string",
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"description": "string",
"entity_schema": "string",
"entity_filters": {
"filter": {
"items": [
{
"key": "string",
"operator": "string",
"value": "string"
}
],
"combination": "string"
}
},
"_purpose": ["string"],
"_manifest": ["123e4567-e89b-12d3-a456-426614174000"],
"__additional": {}
}

deleteTargetโ€‹

Delete a specific target entity by a given id

DELETE /v1/target/{targetId}

const { data } = await client.deleteTarget({
targetId: 'example',
})
Response
{
"_id": "123e4567-e89b-12d3-a456-426614174000",
"_schema": "target",
"_org": "string",
"_tags": ["string"],
"_files": {
"$relation": [
{
"entity_id": "123e4567-e89b-12d3-a456-426614174000",
"_tags": ["string"]
}
]
},
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_title": "string",
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"description": "string",
"entity_schema": "string",
"entity_filters": {
"filter": {
"items": [
{
"key": "string",
"operator": "string",
"value": "string"
}
],
"combination": "string"
}
},
"_purpose": ["string"],
"_manifest": ["123e4567-e89b-12d3-a456-426614174000"],
"__additional": {}
}

patchTargetโ€‹

Partially update a specific target entity's properties by a given id and a given payload

PATCH /v1/target/{targetId}

const { data } = await client.patchTarget(
{
targetId: 'example',
},
{
_schema: 'target',
name: 'string',
description: 'string',
entity_schema: 'string',
entity_filters: {
filter: {
items: [
{
key: 'string',
operator: 'string',
value: 'string'
}
],
combination: 'string'
}
},
_tags: ['string'],
_purpose: ['string'],
_files: {
$relation: [
{
entity_id: '123e4567-e89b-12d3-a456-426614174000',
_tags: ['string']
}
]
},
_manifest: ['123e4567-e89b-12d3-a456-426614174000'],
__additional: {}
},
)
Response
{
"_id": "123e4567-e89b-12d3-a456-426614174000",
"_schema": "target",
"_org": "string",
"_tags": ["string"],
"_files": {
"$relation": [
{
"entity_id": "123e4567-e89b-12d3-a456-426614174000",
"_tags": ["string"]
}
]
},
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_title": "string",
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"description": "string",
"entity_schema": "string",
"entity_filters": {
"filter": {
"items": [
{
"key": "string",
"operator": "string",
"value": "string"
}
],
"combination": "string"
}
},
"_purpose": ["string"],
"_manifest": ["123e4567-e89b-12d3-a456-426614174000"],
"__additional": {}
}

updateTargetโ€‹

Completly replace a specific target entity's properties by a given id and a given payload

PUT /v1/target/{targetId}

const { data } = await client.updateTarget(
{
targetId: 'example',
},
{
_schema: 'target',
name: 'string',
description: 'string',
entity_schema: 'string',
entity_filters: {
filter: {
items: [
{
key: 'string',
operator: 'string',
value: 'string'
}
],
combination: 'string'
}
},
_tags: ['string'],
_purpose: ['string'],
_files: {
$relation: [
{
entity_id: '123e4567-e89b-12d3-a456-426614174000',
_tags: ['string']
}
]
},
_manifest: ['123e4567-e89b-12d3-a456-426614174000'],
__additional: {}
},
)
Response
{
"_id": "123e4567-e89b-12d3-a456-426614174000",
"_schema": "target",
"_org": "string",
"_tags": ["string"],
"_files": {
"$relation": [
{
"entity_id": "123e4567-e89b-12d3-a456-426614174000",
"_tags": ["string"]
}
]
},
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_title": "string",
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"description": "string",
"entity_schema": "string",
"entity_filters": {
"filter": {
"items": [
{
"key": "string",
"operator": "string",
"value": "string"
}
],
"combination": "string"
}
},
"_purpose": ["string"],
"_manifest": ["123e4567-e89b-12d3-a456-426614174000"],
"__additional": {}
}

Schemasโ€‹

BaseErrorโ€‹

type BaseError = {
status: number
message: string
}

ServerErrorโ€‹

type ServerError = {
status: number
message: string
}

ClientErrorโ€‹

type ClientError = {
status: number
message: string
}

BaseUUIDโ€‹

type BaseUUID = string // uuid

BaseTagsโ€‹

type BaseTags = string[]

BasePurposeโ€‹

type BasePurpose = string[]

BaseRelationโ€‹

type BaseRelation = {
$relation?: Array<{
entity_id?: string // uuid
_tags?: string[]
}>
}

BaseEntityOwnerโ€‹

The user / organization owning this entity.

Note: Owner implicitly has access to the entity regardless of ACLs.

type BaseEntityOwner = {
org_id: string
user_id?: string
}

BaseEntityAclโ€‹

Access control list (ACL) for an entity. Defines sharing access to external orgs or users.

type BaseEntityAcl = {
view?: string[]
edit?: string[]
delete?: string[]
}

BaseSystemFieldsโ€‹

type BaseSystemFields = {
_tags?: string[]
_purpose?: string[]
_files?: {
$relation?: Array<{
entity_id?: { ... }
_tags?: { ... }
}>
}
_manifest?: string // uuid[]
__additional?: Record<string, unknown>
}

BaseSystemReadonlyFieldsโ€‹

type BaseSystemReadonlyFields = {
_id?: string // uuid
_schema?: string
_org?: string
_tags?: string[]
_files?: {
$relation?: Array<{
entity_id?: { ... }
_tags?: { ... }
}>
}
_owners?: Array<{
org_id: string
user_id?: string
}>
_title?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_acl?: {
view?: string[]
edit?: string[]
delete?: string[]
}
}

BaseSystemFieldsRequiredโ€‹

type BaseSystemFieldsRequired = object

BaseTargetโ€‹

type BaseTarget = {
_schema?: "target"
name?: string
description?: string
entity_schema?: string
entity_filters?: {
filter?: {
items?: { ... }
combination?: { ... }
}
}
}

BaseTargetRequiredโ€‹

type BaseTargetRequired = object

Targetโ€‹

type Target = {
_id?: string // uuid
_schema: "target"
_org: string
_tags?: string[]
_files?: {
$relation?: Array<{
entity_id?: { ... }
_tags?: { ... }
}>
}
_owners?: Array<{
org_id: string
user_id?: string
}>
_title?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_acl?: {
view?: string[]
edit?: string[]
delete?: string[]
}
name: string
description?: string
entity_schema?: string
entity_filters?: {
filter?: {
items?: { ... }
combination?: { ... }
}
}
_purpose?: string[]
_manifest?: string // uuid[]
__additional?: Record<string, unknown>
}

TargetCreateโ€‹

type TargetCreate = {
_schema?: "target"
name: string
description?: string
entity_schema?: string
entity_filters?: {
filter?: {
items?: { ... }
combination?: { ... }
}
}
_tags?: string[]
_purpose?: string[]
_files?: {
$relation?: Array<{
entity_id?: { ... }
_tags?: { ... }
}>
}
_manifest?: string // uuid[]
__additional?: Record<string, unknown>
}

TargetPatchโ€‹

type TargetPatch = {
_schema?: "target"
name?: string
description?: string
entity_schema?: string
entity_filters?: {
filter?: {
items?: { ... }
combination?: { ... }
}
}
_tags?: string[]
_purpose?: string[]
_files?: {
$relation?: Array<{
entity_id?: { ... }
_tags?: { ... }
}>
}
_manifest?: string // uuid[]
__additional?: Record<string, unknown>
}