Content Management API > Session
Create a new session
Warning: Experimental API
Please note that this API method is marked as unstable and should be avoided in production environments. Changes may occur at any time without warning, potentially impacting your scripts. We recommend contacting our Support Team to explore alternative approaches that are safer and more reliable!
Body parameters
email string Required
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: "account", id: "312" },}