{"_id":"551ca4e335f9812f008ccd31","category":{"_id":"551c03c1ff892b3700d1c57a","pages":["551c056aefc11923006421e8","551c0b2befc11923006421f3","551c0ce223a1ee190034d0ff","551ca30f7405910d00900a57","551ca412b7a32b3b00d1ef69","551ca4e335f9812f008ccd31","551cac0d35f9812f008ccd38","551cae3bd65a6d19007a8e6a","551caef7b7a32b3b00d1ef70","551cb06448564a2f0024d8a0","551cb24435f9812f008ccd3c","551cb2a8d65a6d19007a8e75","551cb4cfb7a32b3b00d1ef76","552926c5ceedaa0d00bc5c71"],"version":"5435693035740020002a1c1f","__v":14,"project":"5435693035740020002a1c1c","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-04-01T14:42:09.907Z","from_sync":false,"order":7,"slug":"spaces","title":"Spaces"},"editedParams":true,"parentDoc":null,"project":"5435693035740020002a1c1c","version":{"_id":"5435693035740020002a1c1f","__v":14,"project":"5435693035740020002a1c1c","createdAt":"2014-10-08T16:41:20.702Z","releaseDate":"2014-10-08T16:41:20.702Z","categories":["5435693035740020002a1c20","551c03c1ff892b3700d1c57a","551ca3927405910d00900a59","551cac6448564a2f0024d89e","551cb4d848564a2f0024d8a3","551cb52db7a32b3b00d1ef78","5526e2064a7ac121004c6073","5526e5147d4a4417009516b3","5526e9877d4a4417009516bb","5528362cd9e1db2d00cd924d","5580240ebe698419008f2ba2","5580a7dabe698419008f2db6","568161799de23c0d00c54750","5866c905a2cbb31900f6f1aa"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"user":"543569cd35740020002a1c2d","__v":2,"editedParams2":true,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-02T02:09:39.882Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"method":"post","results":{"codes":[{"name":"","code":"{\n    \"meta\": {\n        \"status_code\": 200,\n        \"status\": \"OK\",\n        \"message\": \"\",\n        \"more_info\": {}\n    },\n    \"data\": {\n        \"space_id\": 50,\n        \"location_id\": 10,\n        \"user_id\": 42,\n        \"device_id\": 1,\n    \t\t\"last_seen_at\": \"2016-12-30T19:54:38+0000\",\n   \t\t  \"arrived_at\": \"2016-12-30T19:54:38+0000\",\n  \t\t  \"expired_at\": \"2016-12-30T19:56:38+0000\",\n        \"session_ttl\": 120,\n        \"session_active\": true,\n        \"user\": {\n            // The user submodel\n        },\n        \"device\": {\n            // The device submodel\n        }\n    }\n}","language":"json","status":200},{"language":"json","status":201,"code":"{\n    \"meta\": {\n        \"status_code\": 201,\n        \"status\": \"CREATED\",\n        \"message\": \"\",\n        \"more_info\": {}\n    },\n    \"data\": {\n        \"space_id\": 1,\n        \"location_id\": 1,\n        \"user_id\": 1,\n        \"device_id\": 2,\n        \"last_seen_at\": \"2015-03-05T16:54:53+0000\",\n        \"arrived_at\": null,\n        \"expired_at\": \"2015-03-05T16:55:23+0000\",\n        \"session_ttl\": 30,\n        \"session_active\": true,\n        \"user\": {\n            \"id\": 1,\n            \"name\": \"Admin\",\n            \"slug\": \"admin\",\n            \"avatar\": \"\",\n            \"created_at\": \"2014-12-02T22:24:12+0000\",\n            \"updated_at\": \"2014-12-02T22:24:12+0000\",\n            \"primary_email\": {\n                \"email\": \"admin:::at:::robinpowered.com\",\n                \"is_verified\": false\n            }\n        },\n        \"device\": {\n            \"id\": 2,\n            \"account_id\": 7,\n            \"device_manifest_id\": 1,\n            \"name\": \"My Device\",\n            \"last_reported_at\": \"2015-03-05T16:54:53+0000\",\n            \"created_at\": \"2015-01-08T18:24:46+0000\",\n            \"updated_at\": \"2015-03-05T16:54:53+0000\"\n        }\n    }\n}"}]},"settings":"","examples":{"codes":[{"code":"POST /v1.0/spaces/50/presence HTTP/1.1\nHost: api.robinpowered.com\nContent-Type: application/json\nAuthorization: Access-Token :accessToken\n\n{\n\t\"user_id\": 42,\n\t\"device_id\": 1,\n  \"session_ttl\": 120 \n}","language":"http"}]},"auth":"required","params":[{"_id":"551c0ce223a1ee190034d100","ref":"","in":"path","required":true,"desc":"The ID of the space to post presence to.","default":"","type":"int","name":"id"},{"_id":"551ca58035f9812f008ccd34","ref":"","in":"body","required":false,"desc":"The ID of the user who is present.","default":"","type":"int","name":"user_id"},{"_id":"551ca58035f9812f008ccd33","ref":"","in":"body","required":true,"desc":"The ID of the device reporting the presence. This parameter is only required if `user_ref` is omitted.","default":"","type":"string","name":"device_id"},{"_id":"551ca58035f9812f008ccd32","ref":"","in":"body","required":false,"desc":"How long to extend the presence session for, in seconds. If presence is posted with a TTL of 60 seconds and then again 120 seconds later, Robin will treat these as two separate sessions.","default":"30","type":"int","name":"session_ttl"}],"url":"/spaces/:id/presence"},"isReference":true,"order":10,"body":"Creates or extends an existing presence session for a user or device within a space. This endpoint should be polled on a set interval while the user is present in the space, using a TTL that is longer than that interval.\n\nThe response will either be `201` if the session is newly created or `200` if updated (extended).\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Presence should be posted at a heartbeat interval that is less than the provided TTL. Otherwise, undesired unique presence sessions will be created for every single post instead of properly extending a single session. \\n\\nIf this behavior is detected, the access token at fault for the abuse may be revoked.\",\n  \"title\": \"Keep your presence intervals short\"\n}\n[/block]","excerpt":"Add presence to a space","slug":"add-space-presence","type":"endpoint","title":"/spaces/:id/presence"}

post/spaces/:id/presence

Add presence to a space

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

id:
required
integer
The ID of the space to post presence to.

Body Params

user_id:
integer
The ID of the user who is present.
device_id:
required
string
The ID of the device reporting the presence. This parameter is only required if `user_ref` is omitted.
session_ttl:
integer30
How long to extend the presence session for, in seconds. If presence is posted with a TTL of 60 seconds and then again 120 seconds later, Robin will treat these as two separate sessions.

Examples


Result Format


Documentation

Creates or extends an existing presence session for a user or device within a space. This endpoint should be polled on a set interval while the user is present in the space, using a TTL that is longer than that interval. The response will either be `201` if the session is newly created or `200` if updated (extended). [block:callout] { "type": "warning", "body": "Presence should be posted at a heartbeat interval that is less than the provided TTL. Otherwise, undesired unique presence sessions will be created for every single post instead of properly extending a single session. \n\nIf this behavior is detected, the access token at fault for the abuse may be revoked.", "title": "Keep your presence intervals short" } [/block]

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}