@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Developer documentation
@base https://api.journy.io
@version 1.0.0
@auth ApiKey (inferred from docs)
@endpoints 16
@toc link(1), events(2), users(2), accounts(4), properties(2), validate(1), tracking(1), track(1), segments(2)

@group link
@endpoint POST /link
@required {deviceId: str(non-empty-string), identification: map{email: str(email), userId: str(user-id)}}
@returns(201)
@errors {400, 401, 403, 429, 500}

@endgroup

@group events
@endpoint POST /events
@required {identification: map{account: map, user: map}, name: str(event-name)}
@optional {metadata: map, triggeredAt: str(datetime)}
@returns(201)
@errors {400, 401, 403, 429, 500}

@endpoint GET /events
@returns(200)
@errors {400, 401, 403, 429, 500}

@endgroup

@group users
@endpoint POST /users/upsert
@required {identification: map{email: str(email), userId: str(user-id)}}
@optional {properties: map}
@returns(201)
@errors {400, 401, 403, 429, 500}

@endpoint DELETE /users
@required {identification: map{email: str(email), userId: str(user-id)}}
@returns(202)
@errors {400, 401, 403, 429, 500}

@endgroup

@group accounts
@endpoint POST /accounts/upsert
@required {identification: map{domain: str(top-level-domain), accountId: str(account-id)}}
@optional {properties: map}
@returns(201)
@errors {400, 401, 403, 429, 500}

@endpoint POST /accounts/users/add
@required {account: map{domain: str(top-level-domain), accountId: str(account-id)}, users: [map{identification!: map, properties: map}]}
@returns(201)
@errors {400, 401, 429, 500}

@endpoint POST /accounts/users/remove
@required {account: map{domain: str(top-level-domain), accountId: str(account-id)}, users: [map{identification!: map}]}
@returns(204)
@errors {400, 401, 429, 500}

@endpoint DELETE /accounts
@required {identification: map{domain: str(top-level-domain), accountId: str(account-id)}}
@returns(202)
@errors {400, 401, 403, 429, 500}

@endgroup

@group properties
@endpoint GET /properties/users
@returns(200)
@errors {400, 401, 403, 429, 500}

@endpoint GET /properties/accounts
@returns(200)
@errors {400, 401, 403, 429, 500}

@endgroup

@group validate
@endpoint GET /validate
@returns(200)
@errors {401, 403, 429, 500}

@endgroup

@group tracking
@endpoint GET /tracking/snippet
@required {domain: str(domain)}
@returns(200)
@errors {400, 401, 403, 404, 429, 500}

@endgroup

@group track
@endpoint POST /track
@required {identification: map{account: map, user: map}, name: str(event-name)}
@optional {metadata: map, triggeredAt: str(datetime)}
@returns(201)
@errors {400, 401, 403, 429, 500}

@endgroup

@group segments
@endpoint GET /segments/users
@returns(200)
@errors {400, 401, 403, 429, 500}

@endpoint GET /segments/accounts
@returns(200)
@errors {400, 401, 403, 429, 500}

@endgroup

@end
