> ## 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 Code

> Create or submit link code create via the Junction API. Requires authentication with your team API key.

Used for Junction iOS apps to share Apple HealthKit with you. Please refer [here](/wearables/vital-app/introduction) for more information.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url {{BASE_URL}}/v2/link/code/create\?user_id\=1875c190-0cd6-46c1-8670-5b56a7794b78 \
       --header 'Accept: application/json' \
       --header 'Content-Type: application/json' \
       --header 'x-vital-api-key: <API_KEY>'
  ```

  ```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.link.codeCreate({ userId: "<user_id>" });
  ```

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

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

  data = client.link.code_create(user_id="<user_id>")
  ```

  ```java Java theme={null}
  import com.junction.api.Junction;
  import com.junction.api.core.Environment;
  import com.junction.api.resources.link.requests.CodeCreateLinkRequest;

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

  var data = client.link().codeCreate(
      CodeCreateLinkRequest.builder()
          .userId("<user_id>")
          .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.Link.CodeCreate(context.TODO(), &junction.CodeCreateLinkRequest{
      UserId: "<user_id>",
  })
  if err != nil {
      return err
  }
  fmt.Printf("Received data %s\n", response)
  ```
</RequestExample>


## OpenAPI

````yaml POST /v2/link/code/create
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/link/code/create:
    post:
      tags:
        - link
      summary: Create Token
      description: Generate a token to invite a user of Vital mobile app to your team
      operationId: create_token_v2_link_code_create_post
      parameters:
        - name: user_id
          in: query
          required: true
          schema:
            type: string
            format: uuid
            title: User Id
        - name: expires_at
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            description: >-
              When the link code should expire. Defaults to server time plus 1
              hour.
            title: Expires At
          description: >-
            When the link code should expire. Defaults to server time plus 1
            hour.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VitalTokenCreatedResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    VitalTokenCreatedResponse:
      properties:
        code:
          type: string
          pattern: ^(sk|pk)(eu|us)([\da-f]{8})
          title: Code
        exchange_url:
          type: string
          pattern: ^tryvital\:\/\/tryvital\?code\=(sk|pk)(eu|us)([\da-f]{8})$
          title: Exchange Url
        expires_at:
          type: string
          format: date-time
          title: Expires At
      type: object
      required:
        - code
        - exchange_url
        - expires_at
      title: VitalTokenCreatedResponse
    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

````