> ## Documentation Index
> Fetch the complete documentation index at: https://docs.junction.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Portal URL

> Create a Portal URL for a user via the Junction API. Requires authentication with your team API key.

<Card horizontal icon="person-digging" color="#57164A">
  This feature is in **closed beta**.

  Interested in this feature? Get in touch with your Customer Success Manager.
</Card>

Create a URL to Junction User Portal pre-authorized to a particular User.

Junction User Portal requires that demographics have been specified for the User:

* Use the [Get User Demographics](/api-reference/user/get-info-latest) endpoint to review currently set demographics;
* Use the [Update User Demographics](/api-reference/user/upsert-info) endpoint to update the user's demographics.

<Note>
  If you attempt to create a Portal URL for a user without demographics, you will get a **422 Unprocessable Entity** response.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url {{BASE_URL}}/v2/user/{{USER_ID}}/create_portal_url \
       --header 'Accept: application/json' \
       --header 'x-vital-api-key: <API_KEY>' \
       --header 'Content-Type: application/json' \
       --data '{"context":"launch"}'
  ```

  ```typescript TypeScript theme={null}
  import { JunctionClient, JunctionEnvironment } from "@junction-api/sdk";

  const client = new JunctionClient({
      apiKey: "YOUR_API_KEY",
      environment: JunctionEnvironment.Sandbox,
  });

  const data = await client.user.createPortalUrl({
      userId: "<user_id>",
      context: "launch",
  });
  ```

  ```python Python theme={null}
  from junction import Junction
  from junction.environment import JunctionEnvironment
  from junction.user import CreateUserPortalUrlBodyContext

  client = Junction(
      api_key="YOUR_API_KEY",
      environment=JunctionEnvironment.SANDBOX,
  )

  data = client.user.create_portal_url(
      "<user_id>",
      context=CreateUserPortalUrlBodyContext.LAUNCH,
  )
  ```

  ```java Java theme={null}
  import com.junction.api.Junction;
  import com.junction.api.core.Environment;
  import com.junction.api.resources.user.requests.CreateUserPortalUrlBody;
  import com.junction.api.resources.user.types.CreateUserPortalUrlBodyContext;

  Junction client = Junction.builder()
      .apiKey("YOUR_API_KEY")
      .environment(Environment.SANDBOX)
      .build();

  var data = client.user().createPortalUrl(
      "<user_id>",
      CreateUserPortalUrlBody.builder()
          .context(CreateUserPortalUrlBodyContext.LAUNCH)
          .build()
  );
  ```

  ```go Go theme={null}
  import (
      "context"

      junction "github.com/junction-api/junction-go"
      "github.com/junction-api/junction-go/client"
      "github.com/junction-api/junction-go/option"
  )

  c := client.NewClient(
      option.WithApiKey("YOUR_API_KEY"),
      option.WithBaseURL(junction.Environments.Sandbox),
  )

  response, err := c.User.CreatePortalUrl(context.TODO(), &junction.CreateUserPortalUrlBody{
      UserId:  "<user_id>",
      Context: junction.CreateUserPortalUrlBodyContextLaunch,
  })
  if err != nil {
      return err
  }
  fmt.Printf("Received data %s\n", response)
  ```
</RequestExample>


## OpenAPI

````yaml POST /v2/user/{user_id}/create_portal_url
openapi: 3.1.0
info:
  title: Junction API
  description: https://docs.junction.com/
  version: 0.4.483
servers:
  - url: https://api.us.junction.com
    x-fern-server-name: Production
  - url: https://api.eu.junction.com
    x-fern-server-name: ProductionEU
  - url: https://api.sandbox.us.junction.com
    x-fern-server-name: Sandbox
  - url: https://api.sandbox.eu.junction.com
    x-fern-server-name: SandboxEU
security:
  - apiKeyAuth: []
paths:
  /v2/user/{user_id}/create_portal_url:
    post:
      tags:
        - user
      summary: Create User Portal Url
      operationId: create_user_portal_url_v2_user__user_id__create_portal_url_post
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: User Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserPortalURLBody'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateUserPortalURLResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateUserPortalURLBody:
      properties:
        context:
          type: string
          enum:
            - launch
            - communications
          title: Context
          description: >-
            `launch`: Generates a short-lived (minutes) portal URL that is
            intended for launching a user from your

            authenticated web context directly into the Junction User Portal.
            This URL is not suitable for asynchronous

            communications due to its verbosity as well as short-lived nature.


            `communications`: Generates a long-lived (weeks) but shortened
            portal URL that is suitable for Emails, SMS

            messages and other communication channels. Users may be asked to
            verify their identity with Email and SMS

            authentication, e.g., when they open a short link on a new device.
            ℹ️ This enum is non-exhaustive.
        order_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Order Id
          description: >-
            If specified, the generated URL will deeplink to the specified
            Order.
      type: object
      required:
        - context
      title: CreateUserPortalURLBody
    CreateUserPortalURLResponse:
      properties:
        url:
          type: string
          title: Url
        expires_in:
          type: integer
          title: Expires In
      type: object
      required:
        - url
        - expires_in
      title: CreateUserPortalURLResponse
    HTTPValidationError:
      properties:
        detail:
          title: Detail
      type: object
      title: HTTPValidationError
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-vital-api-key
      description: Vital Team API Key

````