Stytch B2B Magic Links API

The B2B Magic Links API from Stytch — 4 operation(s) for b2b magic links.

OpenAPI Specification

stytch-b2b-magic-links-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Stytch B2B Authentication Application B2B Magic Links API
  version: 2.0.0
  description: Stytch's B2B API for multi-tenant authentication. Supports Organizations, Members, SSO (SAML/OIDC), Magic Links, OTP, OAuth, Discovery, Sessions, B2B RBAC, SCIM, TOTP, Recovery Codes, Passwords, Impersonation, and the B2B IDP.
  contact:
    name: Stytch
    url: https://stytch.com/docs
  license:
    name: Proprietary
servers:
- url: https://api.stytch.com
  description: Production
- url: https://test.stytch.com
  description: Test
tags:
- name: B2B Magic Links
paths:
  /v1/b2b/magic_links/authenticate:
    post:
      summary: Authenticate
      operationId: api_b2b_magic_v1_Authenticate
      tags:
      - B2B Magic Links
      description: "Authenticate a Member with a Magic Link. This endpoint requires a Magic Link token that is not expired or previously used. If the Member's status is `pending` or `invited`, they will be updated to `active`.\nProvide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.\n\nIf the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.\nThe `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), \nor [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete the MFA step and acquire a full member session.\nThe `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.\nThe `session_duration_minutes` and `session_custom_claims` parameters will be ignored.\n\nIf a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api_b2b_magic_v1_AuthenticateRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_b2b_magic_v1_AuthenticateResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                status_code: 401
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: unauthorized_credentials
                error_message: Unauthorized credentials.
                error_url: https://stytch.com/docs/api/errors/401
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                status_code: 429
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: too_many_requests
                error_message: Too many requests have been made.
                error_url: https://stytch.com/docs/api/errors/429
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                status_code: 500
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: internal_server_error
                error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
                error_url: https://stytch.com/docs/api/errors/500
      x-code-samples:
      - lang: csharp
        label: C#
        source: "// POST /v1/b2b/magic_links/authenticate\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  magic_links_token: \"${token}\",\n};\n\nclient.MagicLinks.Authenticate(params)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: go
        label: Go
        source: "// POST /v1/b2b/magic_links/authenticate\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/b2bstytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/magiclinks\"\n)\n\nfunc main() {\n\tclient, err := b2bstytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &magiclinks.AuthenticateParams{\n\t\tMagicLinksToken: \"${token}\",\n\t}\n\n\tresp, err := client.MagicLinks.Authenticate(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
      - lang: java
        label: Java
        source: "// POST /v1/b2b/magic_links/authenticate\npackage com.example;\n\nimport com.stytch.java.b2b.models.magiclinks.AuthenticateRequest;\nimport com.stytch.java.b2b.StytchB2BClient;\nimport com.stytch.java.common.StytchResult;\n\npublic class Main {\n    public static void main(String[] args) {\n        StytchB2BClient.configure(\"${projectId}\", \"${secret}\");\n\n        AuthenticateRequest params = new AuthenticateRequest();\n        params.setMagicLinksToken(\"${token}\");\n\n        Object result = StytchB2BClient.getMagicLinks().authenticate(params);\n        if (result instanceof StytchResult.Success) {\n          System.out.println(((StytchResult.Success) result).getValue());\n        } else {\n          System.out.println(((StytchResult.Error) result).getException());\n        }\n    }\n}"
      - lang: kotlin
        label: Kotlin
        source: "// POST /v1/b2b/magic_links/authenticate\npackage com.example\n\nimport com.stytch.java.b2b.StytchB2BClient\nimport com.stytch.java.b2b.models.magiclinks.AuthenticateRequest\n\nfun main() {\n    StytchB2BClient.configure(\n        projectId = \"${projectId}\",\n        secret = \"${secret}\",\n    )\n\n    when (\n        val result =\n            StytchB2BClient.magicLinks.authenticate(\n                AuthenticateRequest(\n                    magicLinksToken = \"${token}\",\n                ),\n            )\n    ) {\n        is StytchResult.Success -> println(result.value)\n        is StytchResult.Error -> println(result.exception)\n    }\n}\n"
      - lang: javascript
        label: Node.js
        source: "// POST /v1/b2b/magic_links/authenticate\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  magic_links_token: \"${token}\",\n};\n\nclient.magicLinks.authenticate(params)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: php
        label: PHP
        source: "$response = $client->magic_links->authenticate([\n    'magic_links_token' => '${token}',\n]);"
      - lang: python
        label: Python
        source: "# POST /v1/b2b/magic_links/authenticate\nfrom stytch import B2BClient\n\nclient = B2BClient(\n    project_id=\"${projectId}\",\n    secret=\"${secret}\",\n)\n\nresp = client.magic_links.authenticate(\n    magic_links_token=\"${token}\",\n)\n\nprint(resp)\n"
      - lang: ruby
        label: Ruby
        source: "# POST /v1/b2b/magic_links/authenticate\nrequire 'stytch'\n\nclient = StytchB2B::Client.new(\n  project_id: \"${projectId}\",\n  secret: \"${secret}\"\n)\n\nresp = client.magic_links.authenticate(\n  magic_links_token: \"${token}\"\n  \n)\n\nputs resp"
      - lang: rust
        label: Rust
        source: "// POST /v1/b2b/magic_links/authenticate\nuse stytch::b2b::client::Client;\nuse stytch::b2b::magic_links::AuthenticateRequest;\n\nfn main() {\n    let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n    let resp = client.magic_links.authenticate(\n        AuthenticateRequest{\n            magic_links_token: \"${token}\",\n            ..Default::default()\n        }\n    ).await;\n    println!(\"The response is {:?}\", resp);\n}"
      - lang: bash
        label: cURL
        source: "# POST /v1/b2b/magic_links/authenticate\ncurl --request POST \\\n  --url https://test.stytch.com/v1/b2b/magic_links/authenticate \\\n  -u '${projectId}:${secret}' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"magic_links_token\": \"${token}\"\n  }'"
  /v1/b2b/magic_links/email/login_or_signup:
    post:
      summary: Loginorsignup
      operationId: api_b2b_magic_v1_b2b_magic_links_email_LoginOrSignup
      tags:
      - B2B Magic Links
      description: 'Send either a login or signup magic link to a Member. A new, pending, or invited Member will receive a signup Email Magic Link. Members will have a `pending` status until they successfully authenticate. An active Member will receive a login Email Magic Link.


        The magic link is valid for 60 minutes.'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api_b2b_magic_v1_b2b_magic_links_email_LoginOrSignupRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_b2b_magic_v1_b2b_magic_links_email_LoginOrSignupResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                status_code: 401
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: unauthorized_credentials
                error_message: Unauthorized credentials.
                error_url: https://stytch.com/docs/api/errors/401
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                status_code: 429
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: too_many_requests
                error_message: Too many requests have been made.
                error_url: https://stytch.com/docs/api/errors/429
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                status_code: 500
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: internal_server_error
                error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
                error_url: https://stytch.com/docs/api/errors/500
      x-code-samples:
      - lang: csharp
        label: C#
        source: "// POST /v1/b2b/magic_links/email/login_or_signup\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  organization_id: \"${organizationId}\",\n  email_address: \"${email}\",\n};\n\nclient.MagicLinks.Email.LoginOrSignup(params)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: go
        label: Go
        source: "// POST /v1/b2b/magic_links/email/login_or_signup\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/b2bstytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/magiclinks/email\"\n)\n\nfunc main() {\n\tclient, err := b2bstytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &email.LoginOrSignupParams{\n\t\tOrganizationID: \"${organizationId}\",\n\t\tEmailAddress:   \"${email}\",\n\t}\n\n\tresp, err := client.MagicLinks.Email.LoginOrSignup(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
      - lang: java
        label: Java
        source: "// POST /v1/b2b/magic_links/email/login_or_signup\npackage com.example;\n\nimport com.stytch.java.b2b.models.magiclinksemail.LoginOrSignupRequest;\nimport com.stytch.java.b2b.StytchB2BClient;\nimport com.stytch.java.common.StytchResult;\n\npublic class Main {\n    public static void main(String[] args) {\n        StytchB2BClient.configure(\"${projectId}\", \"${secret}\");\n\n        LoginOrSignupRequest params = new LoginOrSignupRequest();\n        params.setOrganizationId(\"${organizationId}\");\n        params.setEmailAddress(\"${email}\");\n\n        Object result = StytchB2BClient.getMagicLinks().getEmail().loginOrSignup(params);\n        if (result instanceof StytchResult.Success) {\n          System.out.println(((StytchResult.Success) result).getValue());\n        } else {\n          System.out.println(((StytchResult.Error) result).getException());\n        }\n    }\n}"
      - lang: kotlin
        label: Kotlin
        source: "// POST /v1/b2b/magic_links/email/login_or_signup\npackage com.example\n\nimport com.stytch.java.b2b.StytchB2BClient\nimport com.stytch.java.b2b.models.magiclinksemail.LoginOrSignupRequest\n\nfun main() {\n    StytchB2BClient.configure(\n        projectId = \"${projectId}\",\n        secret = \"${secret}\",\n    )\n\n    when (\n        val result =\n            StytchB2BClient.magicLinks.email.loginOrSignup(\n                LoginOrSignupRequest(\n                    organizationId = \"${organizationId}\",\n                    emailAddress = \"${email}\",\n                ),\n            )\n    ) {\n        is StytchResult.Success -> println(result.value)\n        is StytchResult.Error -> println(result.exception)\n    }\n}\n"
      - lang: javascript
        label: Node.js
        source: "// POST /v1/b2b/magic_links/email/login_or_signup\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  organization_id: \"${organizationId}\",\n  email_address: \"${email}\",\n};\n\nclient.magicLinks.email.loginOrSignup(params)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: php
        label: PHP
        source: "$response = $client->magic_links->email->login_or_signup([\n    'organization_id' => '${organizationId}',\n    'email_address' => '${email}',\n]);"
      - lang: python
        label: Python
        source: "# POST /v1/b2b/magic_links/email/login_or_signup\nfrom stytch import B2BClient\n\nclient = B2BClient(\n    project_id=\"${projectId}\",\n    secret=\"${secret}\",\n)\n\nresp = client.magic_links.email.login_or_signup(\n    organization_id=\"${organizationId}\",\n    email_address=\"${email}\",\n)\n\nprint(resp)\n"
      - lang: ruby
        label: Ruby
        source: "# POST /v1/b2b/magic_links/email/login_or_signup\nrequire 'stytch'\n\nclient = StytchB2B::Client.new(\n  project_id: \"${projectId}\",\n  secret: \"${secret}\"\n)\n\nresp = client.magic_links.email.login_or_signup(\n  organization_id: \"${organizationId}\",\n  email_address: \"${email}\"\n  \n)\n\nputs resp"
      - lang: rust
        label: Rust
        source: "// POST /v1/b2b/magic_links/email/login_or_signup\nuse stytch::b2b::client::Client;\nuse stytch::b2b::magic_links_email::LoginOrSignupRequest;\n\nfn main() {\n    let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n    let resp = client.magic_links.email.login_or_signup(\n        LoginOrSignupRequest{\n            organization_id: \"${organizationId}\",\n            email_address: \"${email}\",\n            ..Default::default()\n        }\n    ).await;\n    println!(\"The response is {:?}\", resp);\n}"
      - lang: bash
        label: cURL
        source: "# POST /v1/b2b/magic_links/email/login_or_signup\ncurl --request POST \\\n  --url https://test.stytch.com/v1/b2b/magic_links/email/login_or_signup \\\n  -u '${projectId}:${secret}' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"organization_id\": \"${organizationId}\",\n    \"email_address\": \"${email}\"\n  }'"
  /v1/b2b/magic_links/email/invite:
    post:
      summary: Invite
      operationId: api_b2b_magic_v1_b2b_magic_links_email_Invite
      tags:
      - B2B Magic Links
      description: 'Send an invite email to a new Member to join an Organization. The Member will be created with an `invited` status until they successfully authenticate. Sending invites to `pending` Members will update their status to `invited`. Sending invites to already `active` Members will return an error.


        The magic link invite will be valid for 1 week.


        ## Revoke an invite


        To revoke an existing invite, use the [Delete Member](https://stytch.com/docs/b2b/api/delete-member) endpoint. This will both delete the invited Member from the target Organization and revoke all existing invite emails.'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api_b2b_magic_v1_b2b_magic_links_email_InviteRequest'
      parameters:
      - name: X-Stytch-Member-Session
        in: header
        required: false
        description: A Stytch session that can be used to run the request with the given member's permissions.
        schema:
          type: string
      - name: X-Stytch-Member-SessionJWT
        in: header
        required: false
        description: A Stytch Session JSON Web Token (JWT) that can be used to run the request with the given member's permissions.
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_b2b_magic_v1_b2b_magic_links_email_InviteResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                status_code: 401
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: unauthorized_credentials
                error_message: Unauthorized credentials.
                error_url: https://stytch.com/docs/api/errors/401
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                status_code: 429
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: too_many_requests
                error_message: Too many requests have been made.
                error_url: https://stytch.com/docs/api/errors/429
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                status_code: 500
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: internal_server_error
                error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
                error_url: https://stytch.com/docs/api/errors/500
      x-code-samples:
      - lang: csharp
        label: C#
        source: "// POST /v1/b2b/magic_links/email/invite\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  organization_id: \"${organizationId}\",\n  email_address: \"${email}\",\n};\n\nconst options = {\n  authorization: {\n    session_token: '${sessionToken}',\n  },\n};\n\nclient.MagicLinks.Email.Invite(params, options)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: go
        label: Go
        source: "// POST /v1/b2b/magic_links/email/invite\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/b2bstytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/magiclinks/email\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/methodoptions\"\n)\n\nfunc main() {\n\tclient, err := b2bstytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &email.InviteParams{\n\t\tOrganizationID: \"${organizationId}\",\n\t\tEmailAddress:   \"${email}\",\n\t}\n\n\toptions := &email.InviteParamsOptions{\n\t\tAuthorization: methodoptions.Authorization{\n\t\t\tSessionToken: \"${sessionToken}\",\n\t\t},\n\t}\n\n\tresp, err := client.MagicLinks.Email.Invite(context.Background(), params, options)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
      - lang: java
        label: Java
        source: "// POST /v1/b2b/magic_links/email/invite\npackage com.example;\n\nimport com.stytch.java.b2b.models.magiclinksemail.InviteRequest;\nimport com.stytch.java.b2b.models.magiclinksemail.InviteRequestOptions;\nimport com.stytch.java.b2b.StytchB2BClient;\nimport com.stytch.java.common.methodoptions.Authorization;\nimport com.stytch.java.common.StytchResult;\n\npublic class Main {\n    public static void main(String[] args) {\n        StytchB2BClient.configure(\"${projectId}\", \"${secret}\");\n\n        InviteRequest params = new InviteRequest();\n        params.setOrganizationId(\"${organizationId}\");\n        params.setEmailAddress(\"${email}\");\n\n        InviteRequestOptions options = new InviteRequestOptions();\n        Authorization authorization = new Authorization();\n        authorization.setSessionToken(\"${sessionToken}\");\n        options.setAuthorization(authorization);\n\n        Object result = StytchB2BClient.getMagicLinks().getEmail().invite(params, options);\n        if (result instanceof StytchResult.Success) {\n          System.out.println(((StytchResult.Success) result).getValue());\n        } else {\n          System.out.println(((StytchResult.Error) result).getException());\n        }\n    }\n}"
      - lang: kotlin
        label: Kotlin
        source: "// POST /v1/b2b/magic_links/email/invite\npackage com.example\n\nimport com.stytch.java.b2b.StytchB2BClient\nimport com.stytch.java.b2b.models.magiclinksemail.InviteRequest\nimport com.stytch.java.b2b.models.magiclinksemail.InviteRequestOptions\nimport com.stytch.java.common.methodoptions.Authorization\n\nfun main() {\n    StytchB2BClient.configure(\n        projectId = \"${projectId}\",\n        secret = \"${secret}\",\n    )\n\n    when (\n        val result =\n            StytchB2BClient.magicLinks.email.invite(\n                InviteRequest(\n                    organizationId = \"${organizationId}\",\n                    emailAddress = \"${email}\",\n                ),\n                InviteRequestOptions(\n                    Authorization(\n                        sessionToken = \"${sessionToken}\",\n                    ),\n                ),\n            )\n    ) {\n        is StytchResult.Success -> println(result.value)\n        is StytchResult.Error -> println(result.exception)\n    }\n}\n"
      - lang: javascript
        label: Node.js
        source: "// POST /v1/b2b/magic_links/email/invite\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  organization_id: \"${organizationId}\",\n  email_address: \"${email}\",\n};\n\nconst options = {\n  authorization: {\n    session_token: '${sessionToken}',\n  },\n};\n\nclient.magicLinks.email.invite(params, options)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: php
        label: PHP
        source: "$response = $client->magic_links->email->invite([\n    'organization_id' => '${organizationId}',\n    'email_address' => '${email}',\n], [\n        'authorization' => ['session_token' => '${sessionToken}'],\n\n]);"
      - lang: python
        label: Python
        source: "# POST /v1/b2b/magic_links/email/invite\nfrom stytch import B2BClient\nfrom stytch.b2b.models.magic_links_email import InviteRequestOptions\nfrom stytch.shared.method_options import Authorization\n\nclient = B2BClient(\n    project_id=\"${projectId}\",\n    secret=\"${secret}\",\n)\n\nresp = client.magic_links.email.invite(\n    organization_id=\"${organizationId}\",\n    email_address=\"${email}\",\n    method_options=InviteRequestOptions(\n        authorization=Authorization(\n            session_token=\"${sessionToken}\",\n        ),\n    ),\n)\n\nprint(resp)\n"
      - lang: ruby
        label: Ruby
        source: "# POST /v1/b2b/magic_links/email/invite\nrequire 'stytch'\n\nclient = StytchB2B::Client.new(\n  project_id: \"${projectId}\",\n  secret: \"${secret}\"\n)\n\nresp = client.magic_links.email.invite(\n  organization_id: \"${organizationId}\",\n  email_address: \"${email}\",\n  method_options: StytchB2B::MagicLinks::Email::InviteRequestOptions.new(\n    authorization: Stytch::MethodOptions::Authorization.new(session_token: '${sessionToken}')\n  )\n)\n\nputs resp"
      - lang: rust
        label: Rust
        source: "// POST /v1/b2b/magic_links/email/invite\nuse stytch::b2b::client::Client;\nuse stytch::b2b::magic_links_email::InviteRequest;\n\nfn main() {\n    let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n    let resp = client.magic_links.email.invite(\n        InviteRequest{\n            organization_id: \"${organizationId}\",\n            email_address: \"${email}\",\n            ..Default::default()\n        }\n    ).await;\n    println!(\"The response is {:?}\", resp);\n}"
      - lang: bash
        label: cURL
        source: "# POST /v1/b2b/magic_links/email/invite\ncurl --request POST \\\n  --url https://test.stytch.com/v1/b2b/magic_links/email/invite \\\n  -u '${projectId}:${secret}' \\\n  -H 'Content-Type: application/json' \\\n  -H \"X-Stytch-Member-Session: ${sessionToken}\" \\\n  -d '{\n    \"organization_id\": \"${organizationId}\",\n    \"email_address\": \"${email}\"\n  }'"
  /v1/b2b/magic_links/discovery/authenticate:
    post:
      summary: Authenticate
      operationId: api_b2b_magic_v1_b2b_magic_links_discovery_Authenticate
      tags:
      - B2B Magic Links
      description: Authenticates the Discovery Magic Link token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api_b2b_magic_v1_b2b_magic_links_discovery_AuthenticateRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_b2b_magic_v1_b2b_magic_links_discovery_AuthenticateResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                status_code: 401
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: unauthorized_credentials
                error_message: Unauthorized credentials.
                error_url: https://stytch.com/docs/api/errors/401
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                status_code: 429
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: too_many_requests
                error_message: Too many requests have been made.
                error_url: https://stytch.com/docs/api/errors/429
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                status_code: 500
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: internal_server_error
                error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
                error_url: https://stytch.com/docs/api/errors/500
      x-code-samples:
      - lang: csharp
        label: C#
        source: "// POST /v1/b2b/magic_links/discovery/authenticate\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  discovery_magic_links_token: \"${token}\",\n};\n\nclient.MagicLinks.Discovery.Authenticate(params)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: go
        label: Go
        source: "// POST /v1/b2b/magic_links/discovery/authenticate\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/b2bstytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/b2b/magiclinks/discovery\"\n)\n\nfunc main() {\n\tclient, err := b2bstytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &discovery.AuthenticateParams{\n\t\tDiscoveryMagicLinksToken: \"${token}\",\n\t}\n\n\tresp, err := client.MagicLinks.Discovery.Authenticate(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
      - lang: java
        label: Java
        source: "// POST /v1/b2b/magic_links/discovery/authenticate\npackage com.example;\n\nimport com.stytch.java.b2b.models.magiclinksdiscovery.AuthenticateRequest;\nimport com.stytch.java.b2b.StytchB2BClient;\nimport com.stytch.java.common.StytchResult;\n\npublic class Main {\n    public static void main(String[] args) {\n        StytchB2BClient.configure(\"${projectId}\", \"${secret}\");\n\n        AuthenticateRequest params = new AuthenticateRequest();\n        params.setDiscoveryMagicLinksToken(\"${token}\");\n\n        Object result = StytchB2BClient.getMagicLinks().getDiscovery().authenticate(params);\n        if (result instanceof StytchResult.Success) {\n          System.out.println(((StytchResult.Success) result).getValue());\n        } else {\n          System.out.println(((StytchResult.Error) result).getException());\n        }\n    }\n}"
      - lang: kotlin
        label: Kotlin
        source: "// POST /v1/b2b/magic_links/discovery/authenticate\npackage com.example\n\nimport com.stytch.java.b2b.StytchB2BClient\nimport com.stytch.java.b2b.models.magiclinksdiscovery.AuthenticateRequest\n\nfun main() {\n    StytchB2BClient.configure(\n        projectId = \"${projectId}\",\n        secret = \"${secret}\",\n    )\n\n    when (\n        val result =\n            StytchB2BClient.magicLinks.discovery.authenticate(\n                AuthenticateRequest(\n                    discoveryMagicLinksToken = \"${token}\",\n                ),\n            )\n    ) {\n        is StytchResult.Success -> println(result.value)\n        is StytchResult.Error -> println(result.exception)\n    }\n}\n"
      - lang: javascript
        label: Node.js
        source: "// POST /v1/b2b/magic_links/discovery/authenticate\nconst stytch = require('stytch');\n\nconst client = new stytch.B2BClient({\n  project_id: '${projectId}',\n  secret: '${secret}',\n});\n\nconst params = {\n  discovery_magic_links_token: \"${token}\",\n};\n\nclient.magicLinks.discovery.authenticate(params)\n  .then(resp => { console.log(resp) })\n  .catch(err => { console.log(err) });"
      - lang: php
        label: PHP
        source: "$response = $client->magic_links->discovery->authenticate([\n    'discovery_magic_links_token' => '${token}',\n]);"
      - lang: python
        label: Python
        source: "# POST /v1/b2b/magic_links/discovery/authenticate\nfrom stytch import B2BClient\n\nclient = B2BClient(\n    project_id=\"${projectId}\",\n    secret=\"${secret}\",\n)\n\nres

# --- truncated at 32 KB (119 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/stytch/refs/heads/main/openapi/stytch-b2b-magic-links-api-openapi.yml