Version: 0.2

Stagecast API

Initial draft of the Stagecast Event Management API

Contact: stefan@stagecast.se

Table of contents

User location tracking

Authentication

Friends

Events

Moments

Content

Moment classes

Items

Templates

Triggers

Payments and products

Miscellaneous

User location tracking

0.0.1 Implicit user location tracking (DEPRECATED)

Comment

This is a general concept that applies to all requests, regardless of what method or path is being used. We would like to track the location of users as much as possible (in order to detect when they change status to "attending" in an event). We therefore want to piggyback location information to every request that is made. So, if the user permits geolocation monitoring, you should, whenever you make a request, add an HTTP header X-Location with the latitude and longitude as a space separated string (with latitude first). If the user does not permit X-Location you can either skip to add this header or else add a location somewhere in the pacific ocean (a position where there will never be an event). This only applies for the requests from the apps. The web frontend is not doing positioning. See example below

Request

{Any method - GET, POST, DELETE, ...} /api/{any path} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Location: 59.339865 18.039045
Content-Type: application/json
Content-Length: X

{
   ...whatever info you are sending...
}
	  
If you have no particular request to do but still want to upload the location you can do this with a HTTP GET to /api/nop. This will return 200 OK but do nothing else but to store the location data sent in the headers as above.

0.0.2 Explicit user location tracking

Request

{Any method - GET, POST, DELETE, ...} /api/location HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Location: 59.339865 18.039045
Content-Type: application/json
Content-Length: X

	  
This will update the user's location on the server

Authentication

0.1 Registering a user

Request

POST /api/users/register HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: X

{
	"email": "name@domain.com",
        ... any other user info we might have ...
}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close
	  

Comment

Nothing is returned in the registration. To obtain a token you need to login using the credentials submitted during activation.

0.2 Activating a user

Request

POST /api/users/activate HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: X

{
	"email": "name@domain.com",
        "password": "some password",
        ... any other user info we might have ...
}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close
	  

Comment

Nothing is returned in the activation. To obtain a token you need to login using the credentials submitted during activation.

0.3 Logging in (stagecast login)

Request

POST /api/users/login HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-DeviceToken: asdasjlkasdjlkasdjlkasdasdjlaksdas
Content-Type: application/json
Content-Length: X

{
	"email": "name@domain.com",
	"password": "some password",
        "language": "sv"
}
	  

Comment

The language field in the login request is a language code according to ISO 639-1

The header X-DeviceToken is the Firebase token from the device

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

{
        "role": "mobile",
	"token": "secret token",
        "name": "Some name",
        "firstLogin": true,
        ...
}
	  

Comment

On success a json document with a token is returned. Use this tokens in subsequent requests. The firstLogin field indicates if this is the first login that the user has ever done.

0.4 Logging in (facebook login)

Request

POST /api/users/login HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-DeviceToken: asdasjlkasdjlkasdjlkasdasdjlaksdas
Content-Type: application/json
Content-Length: X

{
	"fbToken": "...the facebook token as retrieved when logging in to fb",
        "fbUserId": "...the facebook user id as retrieved from fb login api",
        "language": "sv",
        "application": "telia_locator"
}
	  

Comment

The language field in the login request is a language code according to ISO 639-1

The application field can be currently either "default" (which happens if you do not set it at all) or "telia_locator"

The header X-DeviceToken is the Firebase token from the device

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

{
        "role": "mobile",
	"token": "secret token",
        "name": "some name",
        "firstLogin": true,
        ...
}
	  

Comment

On success a json document with a token is returned. Use this tokens in subsequent requests. The firstLogin field indicates if this is the first login that the user has ever done.

0.5 Forgot password request

Request

PUT /api/users/password/forgot HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: X

{
	"email": "name@domain.com"
}
	  

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Comment

On success a unique (relatively short-lived) password-change token will be generated in the backend db. A URL to reset the password will be sent out to the email address in the request if the email address exists in the db. Backend will return a 201 code even if email does not exists so that you may not use this interface to check if a user exists or not. An email will however not be sent out if the email does not exist in the db.

Note: Currently the URL sent out in the email is set to https://stagecast.se/passwordChange?token=<some token>, where <some token> is the unique token generated by the server. This does currently not correspond to an existing page on stagecast.se. We can easily change this URL to whatever we want when this page is implemented. Contact stefan@stagecast.se to initiate this change.

0.6 Reset password request

Request

PUT /api/users/password/reset HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: X

{
	"email": "name@domain.com",
	"token": "...the unique password-change token communicated in the URL in the email to the user",
        "password": "...the new password that the user wishes to set"
}
	  

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Comment

On success (if the token is valid and matches the email address) the new password is set in the db. Note that a "201 Created" will be returned even if the token is incorrect to make brute force attempts more difficult.

0.6.1 Change password request

Request

PUT /api/users/password/change HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: X

{
	"email": "name@domain.com",
	"oldPassword": "...the old password",
        "newPassword": "...the new password that the user wishes to set"
}
	  

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Content-Length: 0
Connection: close

	  

0.6.2 Update user info request

Request

PUT /api/users/{user_id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: X

{
	"name": "My new name",
        "language": "sv",
}
	  

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Content-Length: 0
Connection: close

	  

0.7 Migrate account to facebook account

Request

POST /api/users/migrate HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{
	"fbToken": "...the facebook token as retrieved when logging in to fb",
        "fbUserId": "...the facebook user id as retrieved from fb login api"
}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

{
	"token": "secret token",
        "name": "some name",
        ...
}
	  

Comment

On success a json document with a token and other information is returned. This will be the same token as the user you were authenticated had. Then there can be some other information such as email and name returned (same as what is returned from the login request)

0.7.1 Migrate account to stagecast account

Request

POST /api/users/migrate HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{
    "email": "some email",
    "password": "the password to set on the new account",
    "name": "the name of the user"
}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

{
	"token": "secret token",
        "name": "some name",
        ...
}
	  

Comment

On success a json document with a token and other information is returned. This will be the same token as the user you were authenticated had. Then there can be some other information such as email and name returned (same as what is returned from the login request)

0.7.2 Delete account

Request

DELETE /api/users/{uid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

	  

Comment

On success the account and everything associated with it will be removed from the system. All content etc. You may only delete your own account. You may not delete other people's accounts.

0.7.3 Convert account to a higher role

Request

POST /api/users/convert HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{
    "companyRole": "Designer",
    "phone": "82382383838",
    "company": "Acme Inc.",
    "firstName": "Ulfonso",
    "lastName": "Ulfonsson",
    "eventType": "notyourtype"
}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

	  

Comment

A request to promote the logged in account to the suggested role will be submitted.

Friends

0.8 Add friend

Request

POST /api/users/{uid}/friends HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{
    "userId": "some email of the friend you like to add"
}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close
	  

Comment

Only the user indicated by {uid} is currently allowed to do this request - so nobody else can make friends for you

0.8.1 Remove friend

Request

DELETE /api/users/{uid}/friends/{fid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close
	  

Comment

Only the user indicated by {uid} is currently allowed to do this request - so nobody else can unfriend people for you

0.8.2 List friends

Request

GET /api/users/{uid}/friends HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

[{"_id": "abc@abc.com", "name": "Abc "}, {"_id": "stefan@hellkvist.org", ...}, ...]
	  

Comment

Only the user indicated by {uid} is currently allowed to do this request - so nobody else can see your friends. The returned list is a list of user objects

If you would like to get not only the user id:s and name but also the location of each user you can pass the parameter "?location=true" at the end of the URL.

0.8.3 List received invites

Request

GET /api/users/{uid}/invites HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

[{"_id": "abc@abc.com", "name": "Abc "}, {"_id": "stefan@hellkvist.org", ...}, ...]
	  

Comment

Returns a list of user objects with users that have invited you to become friends with them

0.8.4 List sent invites

Request

GET /api/users/{uid}/invites_sent HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

[{"_id": "abc@abc.com", "name": "Abc "}, {"_id": "stefan@hellkvist.org", ...}, ...]
	  

Comment

Returns a list of user objects that you have invited to become friends with you

0.8.5 Accept/ignore invites

Request

POST /api/users/{uid}/invites/{targetId} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{"accepted": true}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close
	  

Comment

Moves a user id (targetId) from the invites list to the friends lists of the two users if accepted = true. Otherwise it will just remove it from the invites list (ignored invite).

0.8.6 Search for users

Request

GET /api/users/search?q={some search query} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

[{"_id": "stefan@hellkvist.org", ...}, ...]
	  

Comment

Free text search specified by the query parameter 'q' matching on names and emails of users. Sub-word matches does not work however as this is based on our DB's text search capabilities. This means that searching for "Stefan" will match users "Stefan Hellkvist" but not "John Stefanopolos". Searching for "Hellkvist" will match "Stefan Hellkvist" and also a user with email lisa@hellkvist.org.

Use offset and limit to select what entries to return

0.8.7 Set visibility to users

Request

POST /api/users/visibility HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{"visibility": true}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Comment

Setting your visibility to false will hide your location to your friends and you will not show up on the map

0.8.8 Get your visibility

Request

GET /api/users/visibility HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 21
Connection: close

{"visibility": true}
	  

Comment

The response indicates if you are currently showing your location to others

0.8.9 Poke friend

Request

POST /api/users/{uid}/friends/{fid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 21
Connection: close

	  

Comment

This will trigger a poke request to the recipient (fid). A notification will be sent out at every power of 2 pokees. If the user fid will later update the location a notification will be sent back to uid.

0.8.9.1 Get user info

Request

GET /api/users/{uid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
Content-Length: 0

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 21
Connection: close

{"name":"Stefan Hellkvist", "_id":"stefan@hellkvist.org", ...}
	  

Comment

The result shows the public user information

0.8.9.2 Set blocked

Request

POST /api/users/{bid}/block HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

{"block": true}
	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Comment

Block or unblock a user. This will hide any content that the user has posted from you.

0.8.9.3 Get your blocked list

Request

GET /api/users/blocked HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123
Content-Length: X

	  

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 21
Connection: close

["bad_user@domain.com", ...]
	  

Comment

The response indicates what users you are currently blocking

Events

1.1 Listing events

Request

GET /api/events HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Use optional parameter owner=1 to select events that you own (events that were created by the user id associated with X-Token)

Use optional parameter type=current|past to select events that have not started (past) or events that are either live now or will occur in the future. Returned events will be sorted by time - closest first. Events that are currently live will have the field isLive set to true.

Use optional parameter groups=groupid1[,groupid2,...] to select events where the requesting user is belonging to any of the specified groups

Events that are currently live will have the field isLive set to true.

Use optional parameter location=Latitude+Longitude (convert the space to a plus) to select live events nearby a certain location that this user has not yet been shown a popup for. The list can most often be empty. Once you have shown the popup to the user you should add the user to the group "popped" which will mean that this event will not be returned for future listings.

Use optional parameters offset=N and limit=M to select and limit results

Example: GET /api/events?offset=8&limit=10

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

[{
        "_id": "abc1",
	"title": "My cool event",
	"location": "12.345 -97.654",
	"start_time": "2016-10-10T10:00",
	"end_time": "2016-10-10T10:30",
}, {
        "_id": "def34",
	"title": "My next cool event",
	"location": "12.345 -97.654",
	"start_time": "2016-10-11T10:00",
	"end_time": "2016-10-11T10:30",
}]
	  

1.2 Getting one event

Request

GET /api/events/{id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

{id} is the event id as returned in a listing
Example: GET /api/events/abc123

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

{
        "_id": "abc1",
	"title": "My cool event",
	"location": "12.345 -97.654",
	"start_time": "2016-10-10T10:00",
	"end_time": "2016-10-10T10:30",
}
	  

1.2.1 Getting one event by code

Request

GET /api/events/codes/{id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json

	  

Comment

{id} is the event code Example: GET /api/events/codes/4711

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 165
Connection: close

{
        "_id": "abc1",
	"title": "My cool event",
	"location": "12.345 -97.654",
	"start_time": "2016-10-10T10:00",
	"end_time": "2016-10-10T10:30",
        "cdnBaseUrl": "https://d5q8k8cx63nj4.cloudfront.net",
        "baseUrl": "https://stagecast.se"
}
	  

1.3 Creating event

Request

POST /api/events HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
	"title": "My cool event",
	"location": {
            "type": "Point",
            "coordinates": [{Longitude}, {Latitude}]
        },
        "radius": 500,
	"start_time": "2016-10-10T10:00",
	"end_time": "2016-10-10T10:30",
        "moments": []
}
	  

Comment

Most fields are optional except for the location field and the radius field. Radius is specified in meters.

The event create request allows you to specify side effect using headers on the form X-Side-Effect-E, where E can be some side effect and the value is some input value to that side effect. Currently we support the following side effects:

HeaderValue
X-Side-Effect-DuplicateAn event ID that you should inherit the current moment classes and triggers from

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 65
Connection: close

{
	"_id": "gef23"
}
	  

1.4 Updating event

Request

PUT /api/events/{id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
	"title": "My cool event",
	"location": "12.345 -97.654",
	"start_time": "2016-10-10T10:00",
	"end_time": "2016-10-10T10:30",
        "moments": [{"_id":"cow345", ... TBD}, ...]
}
	  

Comment

{id} is the event id as returned in a listing Example: PUT /api/events/abc123

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close
	  

1.4.1 Multiply event

Request

POST /api/events/{id}/multiply HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
	"patchList": [{
		"start_time": 123,
		"end_time": 456
	}, {
		"title": "THIS is a SPECIAL night",
		"start_time": 789,
		"end_time": 4343
	}, ...],
	"adjustTriggers": true
}
	  

Comment

{id} is the event id. The patchList includes a list of changes needed to each new event document. There will be one new event created for each entry in the list with the values in each entry overriding the values in the old event. If you want to create an identical copy you can supply an empty document {}.

adjustTriggers tells the server if you want to adjust the migrated time triggers relative the starting time of the new events. Default is false which would mean that all new time triggers have the same time as their origin.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close
	  

1.5 Deleting event

Request

DELETE /api/events/{id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

{id} is the event id as returned in a listing
Example: DELETE /api/events/abc123

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close
	  

1.6 Websocket channel for one event

Request

Connect WebSocket to the URI ws://stagecast.se/api/events/{id}/ws
(when we enable encryption you change to wss)
	  

Comment

{id} is the event id as returned in a listing
Example: ws://stagecast.se/api/events/abc123/ws

This channel can be used for both listening for events but also to trigger events. Everything sent to the channel will be broadcasted to all listeners of the channel (which at the moment also includes the sender of the message itself)

Response

Messages will be sent to the client in the form of json documents.
Example:

{
        "id": "abc1",
	"type": "start"
}
	  

Comment

The id field's value is the id of the moment corresponding to this message. The type field's value is "start" or "stop".

1.7 Triggering a message to be sent over WebSocket

Request

POST /api/events/{eid}/{mid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
	"type": "start"
}
	  

Comment

{id} is the event id and {mid} is the moment id. "type" can be "start" or "stop"

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Content-Length: 0
Connection: close

	  

1.8 Adding users to user groups

Request

POST /api/events/{eid}/groups/{gid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
	"users": ["user_1", "user_2", ..., "user_n"]
}
	  

Comment

{id} is the event id and {gid} is the group id. Currently we have four group ids - crew, interested, attendees, popped and notification_blacklist, where the notification_blacklist serves as a way to disable the notifications for an event (users added to this group will still receive the moments but not receive any push notifications) and popped is the group of users that have been shown a "thre is a live event nearby" popup.

The posted document contains a list of user id's to be added to the specified group. Only the event owner is allowed to do this operation (except for that anyone can add themselves as "interested")

Response

HTTP/1.1 201 Ok
Content-Type: application/json
Content-Length: 0
Connection: close

	  

1.9 Removing a user from a user group

Request

DELETE /api/events/{eid}/groups/{gid}/{uid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

{id} is the event id, {gid} is the group id, and {uid} is the user id. Only the event owner is allowed to do this operation.

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Content-Length: 0
Connection: close

	  

1.9.1 Getting list of crew members

Request

GET /api/events/{eid}/groups/crew HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

{id} is the event id. You need to be a member of the crew yourself to retrieve the list of crew members.

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Content-Length: 123
Connection: close

["user1@test.com", "user2@"...]
	  

1.9.2 Testing membership of group

Request

GET /api/events/{eid}/groups/{gid}/member HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

{id} is the event id and {gid} must currently be "notification_blacklist". This will return true or false depending on if you are part of a group or not.

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Content-Length: 123
Connection: close

{"isMember":true}
	  

Moments

2.1 Listing moments (user centric)

Request

GET /api/moments HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Will return the most recent and active moment for this particular user as a list of one element if there is such a moment. Otherwise an empty list will be returned. The document in the list will have the fields "moment", "template", "event" and "created" (just like the notifications sent to the phone).

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

[{"moment":"abc123","template":"def456","event":"ghi789","created":1023232}]
	  

2.2 Listing moments (event centric)

Request

GET /api/events/{eid}/moments HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Where {eid} is the id of the event where these moments occurred. Use optional parameters offset=N and limit=M to select and limit results
Use optional parameter active=true to only list active moments.
Example: GET /api/events/123/moments?offset=8&limit=10

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

[{"_id":"1", ... TBD }]
	  

2.3 Getting one moment

Request

GET /api/moments/{id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

{id} is the moment id as returned in a listing
Example: GET /api/moments/abc123

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

{"_id":"1", ... TBD }
	  

2.4 Creating moment

Request

POST /api/events/{eid}/moments HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
  "receivers": {
    "groups": ["interested", "attendees"],
    "custom": ["stefan@hellkvist.org", "hellkvist@gmail.com"]
  }
}
	  

Comment

Where {eid} is the id of the event where this moment occurs. In addition to the fields specified in the request body the server will fill in the following fields: owner (the user id of the user creating the moment), created (a timestamp of the creation of the moment), event (the event ID that of the event this moment is associated with) and, finally, type (which will be user for moments created by mobile users and event for moments created by the backend).

The only field that currently have a meaning to the API server is the receivers field. This will affect which users will be able to see the moment. The receivers document can have a groups field which is an array of groups (currently we have "crew", "interested" and "attendees" defined) and also a "custom" field which is just an array of any user ID you may want to send the moment to (email addresses). The groups is defined relative the event that the moment belongs to.

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 65
Connection: close

{
	"_id": "gef23"
}
	  

2.4.1 Launch moment

Request

POST /api/events/{eid}/momentClasses/{mcId}/moments HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
  "location": "59.343001 18.072532",
  "radius": 500,
  "receivers": {
    "groups": ["interested", "attendees"],
    "custom": ["stefan@hellkvist.org", "hellkvist@gmail.com"]
  },
  "inverted": false
}
	  

Comment

This will create a moment and launch it (so triggering notifications for its start). If you specify a location and radius the receivers of the moment will be selected from the users that happens to be within the radius (in meters). If you do not specify the location or radius the you need to instead specify the receivers of the moment yourself as in the example above - groups and/or custom field.

You can also launch moments for users that are NOT inside the circle you specify with {location, radius} by setting the field "inverted" to true in the request document above.

Note that, for the location based moment triggering, the users that should receive the moment is based on their location at the time of launching the moment. Should they leave the circle later they will still have the moment in their phones. A user entering the circle after moment launch will still not see the moment.

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 65
Connection: close

{
	"_id": "gef23"
}
	  

2.4.2 Updating moment

Request

PUT /api/moments/{mid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 123
X-Token: abc123

{
   "class": "gef23-123123-123sad2-12331-dasd"
}
	  

Comment

Where {mid} is the id of the moment. The fields mentioned in the document in the request body will override the existing fields in the previous moment. Not all fields are allowed to be overridden. Currently you are actually only allowed to override the "class" field of the moment. But more fields can be added when needed.

Response

HTTP/1.1 200 Ok
Content-Type: application/json
Connection: close

	  

2.5 Get global moment state

Request

GET /api/moments/{mid}/state HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123

	  

Comment

Where {mid} is the id of the moment

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

{
	"stefan@hellkvist%2eorg": {"some_field": 12, ...},
	"hellkvist@gmail%2ecom": {"some_field": 12, ...}
}
	  

Comment

The returned document will contain one field per user that has set its state. The field will be user id with all dots replced with

%2e

2.5.1 Delete global moment state

Request

DELETE /api/moments/{mid}/state HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123

	  

Comment

Where {mid} is the id of the moment

Note, you would only be able to delete moment state of sandboxed events or events that you own

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

	  

Comment

The returned document will contain one field per user that has set its state. The field will be user id with all dots replced with

%2e

2.6 Get user moment state

Request

GET /api/moments/{mid}/state/users/{uid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123

	  

Comment

Where {mid} is the id of the moment, {uid} is the user id

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

{
	"some_field": 12,
        ...
}
	  

Comment

The returned document is the same document that the user has set its state to.

2.7 Modify user moment state

Request

POST /api/moments/{mid}/state HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123

{ some state document }

	  

Comment

Where {mid} is the id of the moment. This will set the state for the user identified by the X-Token.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

2.8 Subscribe to state changes

Request

_ /api/moments/{mid}/ws HTTP/1.1
Host: 127.0.0.1:8080

	  

Comment

This is a websocket interface where you open a websocket to the url wss://{host}/api/moments/{mid}/ws. When you initially connect you will receive the complete state for that moment. From then on you will receive only the individual user updates.

2.9 Deleting a moment

Request

DELETE /api/moments/{id} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

{id} is the moment id as returned in a listing
Example: DELETE /api/moments/abc123 Currently you can only delete a moment if you created it yourself or if you are a super user.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Content

3.0 Content - upload

Request

POST /api/events/{eid}/{mid}/content HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 14567
X-Token: abc123

...^B^\ICC_PROFILE...(content data)...
	  

Comment

Upload of content (images, videos, ...). Content is associated with an event {eid}, a moment {mid} and the user id, where user id is determined by the X-Token header.

Content can be also be tagged using the X-Tags header (example: X-Tags: tag1,tag2,tag3). This makes it possible to retrieve content that is tagged below by using the ?tag=some_tag option in the GET requests.

There is a special case for the tag background_image. This is a tag that the owner of the event can set when uploading the background image of the event itself. Using this tag will have the side effect that the event document will also be updated and the field background_image will be set to the ID of the newly uploaded content

If you specify the header "X-Location: Latitude Longitude" when uploading content you will tag the content with a position so that you can later use location and radius in when listing content info to retrieve content within a certain circle.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: close

{"id":"236F092E-80C4-48E7-B0C2-60B3A2B1EC87"}
	  

Comment

The id returned can be used to later lookup metadata of the content, or to download the content.

3.0.1 Content - upload of profile picture

Request

POST /api/users/profile HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 14567
X-Token: abc123

...^B^\ICC_PROFILE...(content data)...
	  

Comment

Upload of profile picture for the user logged in

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: close

{"id":"236F092E-80C4-48E7-B0C2-60B3A2B1EC87"}
	  

Comment

The id returned can be used to later lookup metadata of the content, or to download the content.

3.1 Content - get content info (event/moment centric)

Request

GET /api/events/{eid}/{mid}/content HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

This is used to request information about content associated with a particular event {eid}, moment {mid} and user id (determined by the X-Token header). Content info is sorted (descending) by creation time.

You can add the query parameter ?tag=some_tag if you ask for tagged content.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 451
Connection: close

[{"user":"1","type":"image/jpg","size":149937,"moment":"def456","event":"abc123",
"created":1490255488174,"_id":"236F092E-80C4-48E7-B0C2-60B3A2B1EC87"},...]
	  

Comment

Returns a list of metadata objects for the stored content. Metadata info contains content type and id fields but also the creation/upload time of the content item.

3.1.1 Content - get content info (event centric)

Request

GET /api/events/{eid}/content HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

This is used to request information about content associated with a particular event {eid}, from all users, associated with moments of a certain type specified by the parameter type=momentType (example: type=user)

You can also add the query parameter ?tag=some_tag if you ask for tagged content

You can use ?location=Lat+Long&radius=1500 if you are searching for content posted within a certain radius (in metres) of a point.

You can specify what content you would like to receive by specifying the uploaders modifyer. If you set it to "meandfriends" you will list content that you and your friends have uploaded.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 451
Connection: close

[{"user":"1","type":"image/jpg","size":149937,"moment":"def456","event":"abc123",
"created":1490255488174,"_id":"236F092E-80C4-48E7-B0C2-60B3A2B1EC87"},...]
	  

Comment

Returns a list of metadata objects for the stored content. Metadata info contains content type and id fields but also the creation/upload time of the content item.

3.2 Content - get content info (user centric)

Request

GET /api/content HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

This is used to request information about content associated with a particular user id (determined by the X-Token header) regardless of which event the content was posted. Content is sorted (descending) by time.

It is also possible to use the optional parameter type=momentType (example: GET /api/content/?type=user). If you specify this the response is slightly different. Instead of returning user centric content the response will contain all content generated by all users in moments of type momentType in events owned by the logged in user.

You can specify what content you would like to receive by specifying the uploaders modifyer. If you set it to "meandfriends" you will list content that you and your friends have uploaded. If you specify "me" (which is the default) you will only receive your own content - example: GET /api/content?uploaders=meandfriends

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 451
Connection: close

[{"user":"1","type":"image/jpg","size":149937,"moment":"def456","event":"abc123",
"created":1490255488174,"_id":"236F092E-80C4-48E7-B0C2-60B3A2B1EC87"},...]
	  

Comment

Returns a list of metadata objects for the stored content. Metadata info contains content type and id fields but also the creation/upload time of the content item.

3.2.5 Content - get content info (user centric and moment centric)

Request

GET /api/moments/{mid}/content HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

This is used to request information about content associated with a particular user id (determined by the X-Token header) and moment ID (mid) Content is sorted (descending) by time.

Use offset and limit to do pagination

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 451
Connection: close

[{"_id":"236F092E-80C4-48E7-B0C2-60B3A2B1EC87"}, ...]
	  

3.3 Content - download content

Request

GET /api/content/{cid} HTTP/1.1
Host: 127.0.0.1:8080
Content-Length: 0

	  

Comment

This is used to download the data of a specific content item

If you prefer to download a thumbnail representation of the content you add the parameter thumb=true (example: GET /api/content/abc123?thumb=true). You will then download a (small) PNG thumbnail of the content

Previously this request required you to be authenticated and pass the X-Token header. This is no longer true.

Response

HTTP/1.1 200 OK
Content-Type: image/jpg
Content-Length: 14567
Connection: close

...^B^\ICC_PROFILE...(content data)...
	  

Comment

Returns the content data with the content type specified at upload time. Note that we will restrict download of content to the user's own content, so if a content item is requested that the user (identified by the X-Token header) does not own we will return an error code.

3.3.2 Content - download profile picture

Request

GET /api/users/{user_id}/profile HTTP/1.1
Host: 127.0.0.1:8080
Content-Length: 0

	  

Comment

Used to download the profile picture of a user

Response

HTTP/1.1 200 OK
Content-Type: image/jpg
Content-Length: 14567
Connection: close

...^B^\ICC_PROFILE...(content data)...
	  

Comment

Returns the picture, or a 404 Not found error if the user in question has not set its profile picture to anything

3.4 Content - delete content

Request

DELETE /api/content/{content_id} HTTP/1.1
Host: 127.0.0.1:8080
Content-Length: 0

	  

Comment

Used to delete content of id {content_id}

Response

HTTP/1.1 200 OK
Content-Type: image/jpg
Connection: close

	  

Comment

Returns 200 OK if deleted, or a 404 Not found error if the content was not found for the specified user (you may only delete your own content).

3.5 Content - tag content

Request

PUT /api/content/{content_id}/tag HTTP/1.1
Host: 127.0.0.1:8080
Content-Length: 123

{"tag":"inappropriate","reason":"I find nudity disgusting!"}
	  

Comment

Used to tag content of id {content_id} with tag for a reason

Response

HTTP/1.1 200 OK
Content-Type: image/jpg
Connection: close

	  

Moment classes

4.1 Creating moment class

Request

POST /api/events/{eventId}/momentClasses HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 14567
X-Token: abc123
X-Side-Effect-Inherit-Triggers: abc-234-ch34-abff-0199

{
   moment class information
}
	  

Comment

This will create a moment class and associate it with the event

The moment class create request allows you to specify side effect using headers on the form X-Side-Effect-E, where E can be some side effect and the value is some input value to that side effect. Currently we support the following side effects:

HeaderValue
X-Side-Effect-Inherit-TriggersA moment class ID that you should inherit the current triggers from
X-Side-Effect-DeleteA moment class ID that you should delete - the equivalent of calling 4.4

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 45
Connection: close

{"_id":"236F092E-..."}
	  

Comment

The returned id is the id that should be used when creating a moment and triggering it

4.2 Listing moment classes for an event

Request

GET /api/events/{eventId}/momentClasses HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123

	  

Comment

This will return the moment classes associated with the event

Use uptional parameter triggers=true if you want to include the trigger information in the returned document. Only web frontend should ever do this

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: close

[{"_id":"236F092E-..."}, ...]
	  

Comment

The returned documents are the moment classes associated with the event

4.3 Get moment class

Request

GET /api/momentClasses/{momentClassID} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123

	  

Comment

This will return the moment class

Use uptional parameter triggers=true if you want to include the trigger information in the returned document. Only web frontend should ever do this

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: close

{"_id":"236F092E-..."}
	  

Comment

The returned document is the moment class associated with the event

4.4 Delete moment class

Request

DELETE /api/momentClasses/{momentClassID} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123

	  

Comment

This will delete the moment class from its event

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Comment

This will disassociate the moment class with the event. Note that the moment class might not be deleted if there are moments referencing it. They might still need the information.

4.5 Upload logo for moment class

Request

POST /api/momentClasses/{iid}/logo HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 6500
X-Token: abc123

Image data...
	  

Comment

Uploads an image to be used as the logo of the moment class. As a side effect the item object will be added a field "logo" which has the value of the content id of the uploaded content. If you want to reuse the same logo for many classes you can simply set the logo field to that content id when you create the moment class rather than uploading one logo per moment class.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
Connection: close

{"_id":"some content id"}
	  

Items

5.1 Listing items

Request

GET /api/events/{eid}/items HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Returns a lists of items for the event eid. Use limit and offset to do lazy loading (could potentially be MANY items per event). Use the ?owner=true if you only want to show those that you own.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

[{"_id":"abc123","title":"def456","event":"ghi789","created":1023232,"location":{
            "type": "Point",
            "coordinates": [{Longitude}, {Latitude}]
        }}, ...]
	  

5.2 Get item

Request

GET /api/items/{iid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Returns an item given its id.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

{"_id":"abc123","title":"def456","event":"ghi789","created":1023232, "location":{
            "type": "Point",
            "coordinates": [{Longitude}, {Latitude}]
        }}, ...}
	  

5.3 Create item

Request

POST /api/events/{eid}/items HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 65
X-Token: abc123

{"title":"def456","location":{"type": "Point","coordinates": [{Longitude}, {Latitude}]}}
	  

Comment

Returns the item id. Note that an item needs to have its location set as above or it will not show up on the map. {Longitude} and {Latitude} are floating point values.

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 45
Connection: close

{"_id":"236F092E-..."}
	  

5.4 Delete item

Request

DELETE /api/items/{iid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 65
X-Token: abc123

	  

Comment

Deletes an item given its id

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

5.5 Upload logo for item

Request

POST /api/items/{iid}/logo HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 6500
X-Token: abc123

Image data...
	  

Comment

Uploads an image to be used as the logo of the item. As a side effect the item object will be added a field "logo" which has the value of the content id of the uploaded content.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
Connection: close

{"_id":"some content id"}
	  

5.5.1 Upload logo for item

Request

POST /api/items/{iid}/picture HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 6500
X-Token: abc123

Image data...
	  

Comment

Uploads an image to be used as the large picture of the item. As a side effect the item object will be added a field "picture" which has the value of the content id of the uploaded content.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
Connection: close

{"_id":"some content id"}
	  

5.6 Add viewer of item

Request

POST /api/items/{iid}/viewers HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 6500
X-Token: abc123

{"users":["stefan@hellkvist.org", "hellkvist@gmail.com"]}
	  

Comment

Adds an array of user ids (only Stagecast ID's - the email) to the list of users that can currently view this item.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

5.7 List viewers of item

Request

GET /api/items/{iid}/viewers HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

Return an array of user ids (only Stagecast ID's - the email) which is the list of users that can currently view this item.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

["stefan@hellkvist.org", "hellkvist@gmail.com"]
	  

5.8 Delete viewer of item

Request

DELETE /api/items/{iid}/viewers/{vid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 0
X-Token: abc123

	  

Comment

Deletes the user {vid} as viewer from the list of viewers of this item

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

Templates

6.1 Listing templates

Request

GET /api/templates HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Returns a lists of moment templates. Use limit and offset to do lazy loading (could potentially be MANY templates in the system). Use optional parameter category to retrieve only templates of a certain template category (cast, message, stage...) - like so: GET /api/templates?category=cast

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

[{
	"category": "cast",
	"defaultMessage": "make it flash",
	"name": "flash",
	"description": "Use the phones to flash",
	"type": "FLASH0",
	"owner": "uid",
        "logo": "asasdas-asdas-da-ads-das",
	"created": 1233232322
},
{
	"category": "message",
	"defaultMessage": "new message",
	"name": "notelet",
	"description": "Send a message to the users",
	"type": "NOTL0",
	"owner": "uid",
        "logo": "fsd-fdsf-sdf-sdfdsfsd",
	"created": 122333232322
}]
	  

6.2 Get template

Request

GET /api/templates/{iid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Returns an template given its id.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

{
	"category": "cast",
	"defaultMessage": "make it flash",
	"name": "flash",
	"description": "Use the phones to flash",
	"type": "FLASH0",
	"owner": "uid",
        "logo": "fsd-fdsf-sdf-sdfdsfsd",
	"created": 1233232322
}
	  

6.3 Create template

Request

POST /api/templates HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 65
X-Token: abc123

{
	"category": "cast",
	"defaultMessage": "make it flash",
	"name": "flash",
	"description": "Use the phones to flash",
	"type": "FLASH0",
}
	  

Comment

Returns the template id. Note: only users that are super users may create templates.

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 45
Connection: close

{"_id":"236F092E-..."}
	  

6.4 Delete template

Request

DELETE /api/template/{iid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 65
X-Token: abc123

	  

Comment

Deletes a template given its id (if you are a super user)

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

6.5 Upload logo for template

Request

POST /api/templates/{iid}/logo HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 6500
X-Token: abc123

Image data...
	  

Comment

Uploads an image to be used as the moment template image. As a side effect the template object will be added a field "logo" which has the value of the content id of the uploaded content. This image can be retrieved both as a thumbnail or in the original size by using the content API:s

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
Connection: close

{"_id":"some content id"}
	  

Triggers

7.1 Listing triggers

Request

GET /api/events/{eid}/momentClasses/{cid}/triggers HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Returns a lists of triggers for the event eid and moment class cid. Use limit and offset to do lazy loading if needed, but most likely each moment class will have a small set of triggers.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

[{
    "_id": "adasdasdas",
    "type": "time",
    "when": 234234234234234,
    "duration": 25000,
    "receivers": {
      "groups": ["interested", "attendees"],
      "custom": ["stefan@hellkvist.org", "hellkvist@gmail.com"]
    }
}, {
    "_id": "gffgefre",
    "type": "location",
    "location": {
        "coordinates": [18.067432499999995, 59.34991969999999],
        "type": "Point"
    },
    "radius": 500,
    "duration": 25000,
}]
	  

7.2 Get trigger

Request

GET /api/events/{eid}/momentClasses/{cid}/triggers/{tid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Returns a trigger given its event id, moment class id and trigger id.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

{
    "type": "location",
    "location": {
        "coordinates": [18.067432499999995, 59.34991969999999],
        "type": "Point"
    },
    "radius": 500,
    "duration": 25000
}
	  

7.3 Create trigger

Request

POST /api/events/{eid}/momentClasses/{cid}/triggers HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 65
X-Token: abc123

{
    "type": "location",
    "location": {
        "coordinates": [18.067432499999995, 59.34991969999999],
        "type": "Point"
    },
    "duration": 25000
}
	  

Comment

Returns the trigger id of the created trigger.

The current supported trigger formats are:

Trigger typeDocument formatComment
time
{
	"type": "time",
	"when": 123456,
	"duration": 50000
}
                

when - time when the moment is launched

duration - how long the moment will be active

location
{
	"type": "location",
        "location": {
            "coordinates": [18.067432499999995, 59.34991969999999],
            "type": "Point"
        },
        "radius": 300,
	"activation_time": 123456,
        "inactivation_time": 124000,
	"duration": 50000
}
                

location - the center of the triggering moment area

radius - the radius of the triggering moment area circle

activation_time - (optional) a time when the location trigger starts being active, if missing the trigger is always active

inactivation_time - (optional) a time when the location trigger is inactivated, if missing the trigger will remain aactive after the activation_time

duration - how long the moment will be active

midi
{
	"type": "midi",
        "info": {
            "channel": "1",
            "note": "C4"
        },
        "duration":150000
}
                

channel - the midi channel of the midi signal

note - the midi note

duration - how long the moment will be active

A note velocity > 0 means moment launch and velocity = 0 is moment stop

ltc
{
	"type": "ltc",
        "info": {
            "timecode": "00:11:22:33:44",
            "command": "start"
        },
        "duration":150000
}
                

timecode - the timecode

command - start or stop if the moment should be started or stopped

duration - the duration the moment will be active for

Response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 45
Connection: close

{"_id":"236F092E-..."}
	  

7.4 Delete trigger

Request

DELETE /api/events/{eid}/momentClasses/{cid}/triggers/{tid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 65
X-Token: abc123

	  

Comment

Deletes a trigger given its id

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: close

	  

7.5 Update trigger

Request

PUT /api/events/{eid}/momentClasses/{cid}/triggers/{tid} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: image/jpeg
Content-Length: 6500
X-Token: abc123

{
    "type": "location",
    "location": {
        "coordinates": [18.067432499999995, 59.34991969999999],
        "type": "Point"
    },
    "duration": 22000
}
	  

Comment

This updates an existing trigger with the new document

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
Connection: close

	  

8.1 Listing products

Request

GET /api/products?type=subscriptions  HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
X-Token: abc123
	  

Comment

Return a lists of products. The type parameter can be either "subscriptions" or "onetime"

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65
Connection: close

[{
    "id": "adasdasdas",
    "type": "subscription",
    "name": "really nice product",
    "attendeesLimit": 300,
    "price": 10000,
    "currency": "SEK",
    "description", "An event upgrade to 300 participants"

},
...
]
	  

Miscellaneous

9.0 Spotify Auth Token request

Request

POST /api/token HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
Content-Length: 14567
X-Token: abc123

{}
	  

Comment

This is used to fetch the Spotify API app auth token from the backend server

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: close

{"access_token":"236F092E-...","token_type":"Bearer","expires_in":3000,"scope":""}
	  

Comment

The returned token is valid for expires_in seconds

9.1 Get your contacts

Request

GET /api/contacts?q={query} HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
Content-Type: application/json
X-Token: abc123

	  

Comment

This is used to fetch your contacts. A contact is basically someone that has been "crew" together with you on any event. {query} here is for instance a name.

Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: close

["user1@stagecast.se", "user2@stagecat.se", ...]