Sorry, no results found for "".

Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Session

Create a new session

Body parameters

email string Required

Email

Example: "foo@bar.com"
password string Required

Password

Example: "changeme"
otp_code string Optional

Two-factor authentication one-time password

Example: "123512"

Returns

Returns a resource object of type session

Examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const session = await client.session.create({
email: "foo@bar.com",
password: "changeme",
});
// Check the 'Returned output' tab for the result ☝️
console.log(session);
}
run();
{ id: "eyJCJhbGci.eyJhaWwuY29tIn0.32wQOMci", user: { type: "user", id: "312" } }