Docstore accepts data ("documents") over http and stores it for later use by Condé Nast's various departments. Each document is treated as a separate entity bearing no relation to any other documents previously submitted; it is all non-relational, schema-less data.
Docstore is also tied to Condé Nast's newsletter subscription service, and, depending on what data is in a document submitted to docstore, a user may be signed up to one of Condé Nast's mailing lists or entered into their email marketing database when a document is stored.
A common use of docstore is to store information submitted by users from competitions or survey forms on our websites.
It is, however, general purpose and can be used to store any data whatsoever for almost any purpose, but survey and competition forms is the most common use-case.
Docstore is accessed via http at http://docstore.api.condenet.co.uk/
To create a document in Docstore, data must be sent as POST
data to a known database and collection endpoint, such as http://docstore.api.condenet.co.uk/db/test/test/
.
A request sent to this endpoint will create a document in the test
collection of the test
database.
Docstore has the concept of databases and collections. Generally, a database will be Condé Nast brand specific, and the collection will be 'project' specific. For example, an valid endpoint may be http://docstore.api.condenet.co.uk/db/gq/bally-2015/
, indicating GQ's database and the 'bally-2015' collection.
The below code snippet shows a standard HTML form submitting a document to the 'gq/bally-2015' collection.
<form action="https://docstore.api.condenet.co.uk/db/gq/bally-2015/" method="post">
<p>Your answer</p>
<input type="text" name="competition_answer">
<p>Your email</p>
<input type="email" name="email">
<p>Tick if you wish to receive offers from Condé Nast</p>
<input type="checkbox" name="optin_Condénast">
<p>Tick if you wish to receive offers from carefully selected third parties</p>
<input type="checkbox" name="optin_thirdparty">
<input type="hidden" name="_redirect" value="http://mysite.com/#success">
<button type="submit">Submit answer!</button>
</form>
If this form was submitted, a document would be created in the gq/bally-2015 collection. It is worth noting that Docstore does no validation of data, you as the developer of the form are expected to ensure that the data submitted is 'correct' (for your own definition of correct).
Upon further inspection you will notice a few things
email
, optin_condenast
, optin_thirdparty
are 'special' inputs. If docstore notices these three inputs together, the email and their preferences will be automatically entered into the marketing database._redirect
input and value input will prompt the response from Docstore to include a Location header, which will redirect the user to a new page upon submitting the form. If no redirect value is submitted, no redirect will be issued.You can use Docstore via XMLHTTPRequest
with jQuery (for example):
// create object to hold form data
var form_data = {};
// append email into object
form_data['email'] = $('input[name=email]).val();
// if optin_Condénast was set, append it into the form data
if ($('input[name=optin_Condénast]').is(':checked')) {
form_data['optin_Condénast'] = '1';
}
// if optin_thirdparty was set, append it into the form data
if ($('input[name=optin_thirdparty]').is(':checked')) {
form_data['optin_thirdparty'] = '1';
}
// send the request, and handle a success or fail status accordingly
$.ajax({
url: 'https://docstore.api.condenet.co.uk/db/gq/bally-2015/',
type: 'POST',
data: form_data
}).done(function() {
$('#form-success').show();
}).fail(function () {
$('#form-errors').show();
});
In the above code, the redirect parameter is not required as the javascript code can handle showing a 'success' indicator itself.
optin_
values, ANY value indicates an opt-in. Ie, their presence alone indicates that a user has opted in. Sending a value of '0' or 'false' or any "falsey" value will still result in an opt-in. Beware!201 Created
response with a JSON body indicating the UUID of the document created403 Forbidden
response will be returned_remote_addr
and _user_agent
.