{"__v":0,"_id":"57081d77447c410e00221ae5","category":{"__v":0,"_id":"5705b12221cfed0e00e8c580","project":"56abbf55f25f160d00e17f4e","version":"56abbf55f25f160d00e17f51","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-04-07T01:00:18.230Z","from_sync":false,"order":4,"slug":"server-side-api","title":"Server Side API"},"editedParams":true,"editedParams2":true,"parentDoc":null,"project":"56abbf55f25f160d00e17f4e","user":"56abbec30b9e0b0d00616274","version":{"__v":12,"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-08T21:07:03.347Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"curl -XPOST -H \"Content-type: application/json\" -d '{\n  \"api_key\": \"GAMEAPIKEY\",\n  \"user_id\": 32,\n  \"content\": \"Hello, world\"\n}' 'https://api.kongregate.com/api/private_message.json'","language":"curl","name":"Send Message to User ID"}]},"method":"post","results":{"codes":[{"name":"Send Message to User ID","code":"{\n  \"success\": true\n}","language":"json","status":200},{"name":"User Has Not Played","code":"{\n  \"success\": false,\n  \"errors\": [\n    \"Game cannot send a PM to someone who hasn't played the game within 2 weeks.\"\n  ]\n}","language":"json","status":200}]},"settings":"5707e879cfc0992200c2a419","auth":"required","params":[{"_id":"57081d77447c410e00221aea","ref":"","in":"body","required":true,"desc":"Your private api key","default":"","type":"string","name":"api_key"},{"_id":"57081d77447c410e00221ae9","ref":"","in":"body","required":true,"desc":"The text content to send to the user. Any HTML will be stripped, though *bold* and _italics_ will be rendered.","default":"","type":"string","name":"content"},{"_id":"57081d77447c410e00221ae8","ref":"","in":"body","required":false,"desc":"User id of the recipient of the message","default":"","type":"int","name":"user_id"},{"_id":"57081d77447c410e00221ae7","ref":"","in":"body","required":false,"desc":"Username of the recipient of the message","default":"","type":"string","name":"username"},{"_id":"57081d77447c410e00221ae6","ref":"","in":"body","required":false,"desc":"An image to be included with the message","default":"","type":"string","name":"image_url"}],"url":"/private_message.json"},"isReference":true,"order":13,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note\",\n  \"body\": \"This feature will not function unless we have enabled it for your game. If you would like to have this feature enabled, please [contact us](http://www.kongregate.com/feedbacks/new?type=DevelopmentSupportFeedback)\"\n}\n[/block]\nThis function allows you to send a message to a player through a server-side POST, even if that player is offline. It can be used to let players know about updates, information directly relevant to their game status, or whatever else would make sense. However, please keep the messages relevant and well-targeted. We reserve the right to discontinue access to this API if a game is using it excessively or sending information that is not applicable to the recipient.\n\nThe targeted user must have played the game recently (within two weeks), and only one message can be sent per player per day.\n\nThe `user_id` and `username` parameters are optional, but you must include one or the other.","excerpt":"Send messages to Kongregate users","slug":"server-api-private-message","type":"endpoint","title":"Private Messages"}

postPrivate Messages

Send messages to Kongregate users

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

api_key:
required
string
Your private api key
content:
required
string
The text content to send to the user. Any HTML will be stripped, though *bold* and _italics_ will be rendered.
user_id:
integer
User id of the recipient of the message
username:
string
Username of the recipient of the message
image_url:
string
An image to be included with the message

Examples


Result Format


Documentation

[block:callout] { "type": "info", "title": "Note", "body": "This feature will not function unless we have enabled it for your game. If you would like to have this feature enabled, please [contact us](http://www.kongregate.com/feedbacks/new?type=DevelopmentSupportFeedback)" } [/block] This function allows you to send a message to a player through a server-side POST, even if that player is offline. It can be used to let players know about updates, information directly relevant to their game status, or whatever else would make sense. However, please keep the messages relevant and well-targeted. We reserve the right to discontinue access to this API if a game is using it excessively or sending information that is not applicable to the recipient. The targeted user must have played the game recently (within two weeks), and only one message can be sent per player per day. The `user_id` and `username` parameters are optional, but you must include one or the other.

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 }}