---
title: "Upsert a Target associated with an Upstream in a workspace"
url: "https://nov18-dev.movespot.fyi/apis/konnect-control-planes-configuration-dev-3/versions/76e259e8-9e78-4c0e-ab4a-3df25bddc4f1/operations/upsert-target-with-upstream-in-workspace"
---

> Full API specification: https://nov18-dev.movespot.fyi/apis/konnect-control-planes-configuration-dev-3/versions/76e259e8-9e78-4c0e-ab4a-3df25bddc4f1.md

# Upsert a Target associated with an Upstream in a workspace

`PUT` `/control-planes/{controlPlaneId}/core-entities/{workspace}/upstreams/{UpstreamIdForTarget}/targets/{TargetId}`

Operation ID: `upsert-target-with-upstream-in-workspace`

Create or Update a Target associated with an Upstream using ID or target in a workspace.

## Path parameters

- `controlPlaneId` (string, uuid, required) - The UUID of your control plane. This variable is available in the Konnect manager.
- `UpstreamIdForTarget` (string, required) - ID or target of the Target to lookup
- `TargetId` (string, required) - ID of the Target to lookup
- `workspace` (string, string, required) - The name of the workspace

## Request body (required)

Content types: `application/json`

## Responses

- `200` - Successfully upserted Target

## OpenAPI definition

```yaml
openapi: 3.1.0
info:
  title: Konnect Control Planes Configuration
  version: 3.14.0
servers:
  - url: https://us.api.konghq.com/v2
    description: United-States Production region
  - url: https://eu.api.konghq.com/v2
    description: Europe Production region
  - url: https://au.api.konghq.com/v2
    description: Australia Production region
  - url: https://me.api.konghq.com/v2
    description: Middle-East Production region
  - url: https://in.api.konghq.com/v2
    description: India Production region
  - url: https://sg.api.konghq.com/v2
    description: Singapore Production region
paths:
  /control-planes/{controlPlaneId}/core-entities/{workspace}/upstreams/{UpstreamIdForTarget}/targets/{TargetId}:
    parameters:
      - $ref: "#/components/parameters/controlPlaneId"
    put:
      operationId: upsert-target-with-upstream-in-workspace
      summary: Upsert a Target associated with an Upstream in a workspace
      description: Create or Update a Target associated with an Upstream using ID or
        target in a workspace.
      parameters:
        - $ref: "#/components/parameters/UpstreamIdForTarget"
        - $ref: "#/components/parameters/TargetId"
        - $ref: "#/components/parameters/Workspace"
      requestBody:
        description: Description of the Target
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TargetWithoutParents"
      responses:
        "200":
          description: Successfully upserted Target
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Target"
      tags:
        - Targets
security:
  - konnectAccessToken: []
  - personalAccessToken: []
components:
  parameters:
    controlPlaneId:
      name: controlPlaneId
      in: path
      required: true
      schema:
        type: string
        format: uuid
        example: 9524ec7d-36d9-465d-a8c5-83a3c9390458
      description: The UUID of your control plane. This variable is available in the
        Konnect manager.
    UpstreamIdForTarget:
      description: ID or target of the Target to lookup
      example: 5a078780-5d4c-4aae-984a-bdc6f52113d8
      in: path
      name: UpstreamIdForTarget
      required: true
      schema:
        type: string
    TargetId:
      description: ID of the Target to lookup
      example: 5a078780-5d4c-4aae-984a-bdc6f52113d8
      in: path
      name: TargetId
      required: true
      schema:
        type: string
    Workspace:
      description: The name of the workspace
      in: path
      name: workspace
      required: true
      schema:
        type: string
        format: string
        example: team-payments
  schemas:
    TargetWithoutParents:
      description: A target is an ip address/hostname with a port that identifies an
        instance of a backend service. Every upstream can have many targets, and
        the targets can be dynamically added, modified, or deleted. Changes take
        effect on the fly. To disable a target, post a new one with `weight=0`;
        alternatively, use the `DELETE` convenience method to accomplish the
        same. The current target object definition is the one with the latest
        `created_at`.
      type: object
      properties:
        created_at:
          description: Unix epoch when the resource was created.
          type: number
          nullable: true
        description:
          description: User-defined entity description. Konnect only field, not synced to
            the Gateway.
          type: string
          nullable: true
        failover:
          description: Whether to use this target only as backup or not.
          type: boolean
          default: false
          nullable: true
        id:
          description: A string representing a UUID (universally unique identifier).
          type: string
          nullable: true
        managed_by:
          description: Arbitrary JSON data for client responsible for managing the entity.
            Konnect only field, not synced to the Gateway.
          type: object
          additionalProperties: true
          nullable: true
        tags:
          description: An optional set of strings associated with the Target for grouping
            and filtering.
          type: array
          items:
            description: A string representing a tag.
            type: string
          nullable: true
        target:
          description: The target address (ip or hostname) and port. If the hostname
            resolves to an SRV record, the `port` value will be overridden by
            the value from the DNS record.
          type: string
          nullable: true
        updated_at:
          description: Unix epoch when the resource was last updated.
          type: number
          nullable: true
        upstream:
          description: The unique identifier or the name of the upstream for which to
            update the target.
          type: object
          nullable: true
          properties:
            id:
              type: string
          x-foreign: true
        weight:
          description: The weight this target gets within the upstream loadbalancer
            (`0`-`65535`). If the hostname resolves to an SRV record, the
            `weight` value will be overridden by the value from the DNS record.
          type: integer
          default: 100
          maximum: 65535
          minimum: 0
          nullable: true
      example:
        id: 089292a7-ba3d-4d88-acf0-97b4b2e2621a
        target: 203.0.113.42
        weight: 100
      additionalProperties: false
      required:
        - target
    Target:
      description: A target is an ip address/hostname with a port that identifies an
        instance of a backend service. Every upstream can have many targets, and
        the targets can be dynamically added, modified, or deleted. Changes take
        effect on the fly. To disable a target, post a new one with `weight=0`;
        alternatively, use the `DELETE` convenience method to accomplish the
        same. The current target object definition is the one with the latest
        `created_at`.
      type: object
      properties:
        created_at:
          description: Unix epoch when the resource was created.
          type: number
          nullable: true
        description:
          description: User-defined entity description. Konnect only field, not synced to
            the Gateway.
          type: string
          nullable: true
        failover:
          description: Whether to use this target only as backup or not.
          type: boolean
          default: false
          nullable: true
        id:
          description: A string representing a UUID (universally unique identifier).
          type: string
          nullable: true
        managed_by:
          description: Arbitrary JSON data for client responsible for managing the entity.
            Konnect only field, not synced to the Gateway.
          type: object
          additionalProperties: true
          nullable: true
        tags:
          description: An optional set of strings associated with the Target for grouping
            and filtering.
          type: array
          items:
            description: A string representing a tag.
            type: string
          nullable: true
        target:
          description: The target address (ip or hostname) and port. If the hostname
            resolves to an SRV record, the `port` value will be overridden by
            the value from the DNS record.
          type: string
          nullable: true
        updated_at:
          description: Unix epoch when the resource was last updated.
          type: number
          nullable: true
        upstream:
          description: The unique identifier or the name of the upstream for which to
            update the target.
          type: object
          nullable: true
          properties:
            id:
              type: string
          x-foreign: true
        weight:
          description: The weight this target gets within the upstream loadbalancer
            (`0`-`65535`). If the hostname resolves to an SRV record, the
            `weight` value will be overridden by the value from the DNS record.
          type: integer
          default: 100
          maximum: 65535
          minimum: 0
          nullable: true
      example:
        id: 089292a7-ba3d-4d88-acf0-97b4b2e2621a
        target: 203.0.113.42
        upstream:
          id: 5f1d7e76-2fed-4806-a6af-869984f025cb
        weight: 100
      additionalProperties: false
      required:
        - target
  securitySchemes:
    konnectAccessToken:
      type: http
      scheme: bearer
      description: The Konnect access token is meant to be used by the Konnect
        dashboard and the decK CLI to authenticate with.
    personalAccessToken:
      type: http
      scheme: bearer
      description: The personal access token is meant to be used as an alternative to
        basic-auth when accessing Konnect via APIs. You can generate a Personal
        Access Token (PAT) from the personal access token page in the Konnect
        dashboard.
```
