> ## Documentation Index
> Fetch the complete documentation index at: https://api-doc.fidly.be/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Relation

> Update the editable fields of a relation.

The body carries the relation's fields and nothing else; only those present are applied,
the others keep their value. `address` is the exception: it is **merged** into the stored
address, so sending only `city` leaves the rest of the address alone.

`type` is read-only, and a field belonging to the other relation type is refused. Changing
a company's `vat`, `identifier` or `electronic_address` to one another company of the same
company already carries is refused with `409 duplicate_relation`, unless
`?ignore_duplicate=true` is passed. A request that breaks a rule is refused **as a whole**:
the relation is left completely untouched, never half-updated.



## OpenAPI

````yaml /openapi.json patch /relations/{relation_uuid}
openapi: 3.1.0
info:
  title: Fidly API
  version: 1.0.0
servers:
  - url: https://api.fidly.be
    description: Production
security: []
paths:
  /relations/{relation_uuid}:
    patch:
      tags:
        - relations
      summary: Update Relation
      description: >-
        Update the editable fields of a relation.


        The body carries the relation's fields and nothing else; only those
        present are applied,

        the others keep their value. `address` is the exception: it is
        **merged** into the stored

        address, so sending only `city` leaves the rest of the address alone.


        `type` is read-only, and a field belonging to the other relation type is
        refused. Changing

        a company's `vat`, `identifier` or `electronic_address` to one another
        company of the same

        company already carries is refused with `409 duplicate_relation`, unless

        `?ignore_duplicate=true` is passed. A request that breaks a rule is
        refused **as a whole**:

        the relation is left completely untouched, never half-updated.
      operationId: update_relation_relations__relation_uuid__patch
      parameters:
        - name: relation_uuid
          in: path
          required: true
          schema:
            type: string
            title: Relation Uuid
        - name: ignore_duplicate
          in: query
          required: false
          schema:
            anyOf:
              - type: boolean
              - type: 'null'
            description: >-
              Goes through even when the result would give this company the same
              `vat`, `identifier` or `electronic_address` as another one
              (otherwise refused with `409 duplicate_relation`). Companies only:
              passing it on a contact is refused, since there is no such check
              to waive. Never stored.
            title: Ignore Duplicate
          description: >-
            Goes through even when the result would give this company the same
            `vat`, `identifier` or `electronic_address` as another one
            (otherwise refused with `409 duplicate_relation`). Companies only:
            passing it on a contact is refused, since there is no such check to
            waive. Never stored.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RelationUpdate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/CompanyRelationOut'
                  - $ref: '#/components/schemas/ContactRelationOut'
                discriminator:
                  propertyName: type
                  mapping:
                    company:
                      $ref: '#/components/schemas/CompanyRelationOut'
                    contact:
                      $ref: '#/components/schemas/ContactRelationOut'
                title: Response Update Relation Relations  Relation Uuid  Patch
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    RelationUpdate:
      properties:
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
          description: Read-only after creation.
        email:
          anyOf:
            - type: string
              maxLength: 245
            - type: 'null'
          title: Email
          description: Primary email address.
        phone:
          anyOf:
            - type: string
              maxLength: 45
            - type: 'null'
          title: Phone
          description: Phone number.
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
          description: Preferred language, one of ['fr', 'en', 'nl', 'de'].
        address:
          anyOf:
            - $ref: '#/components/schemas/AddressUpdate'
            - type: 'null'
          description: >-
            Address fields to change, merged into the stored address (see
            below). `null` is refused: a relation always has an address.
        name:
          anyOf:
            - type: string
              maxLength: 245
              minLength: 1
            - type: 'null'
          title: Name
          description: >-
            Company name. Companies only — a contact's name is derived from its
            `first_name`/`last_name`.
        vat:
          anyOf:
            - type: string
              maxLength: 45
            - type: 'null'
          title: Vat
          description: VAT number. Companies only.
        identifier:
          anyOf:
            - type: string
              maxLength: 45
            - type: 'null'
          title: Identifier
          description: Legal registration / party identifier. Companies only.
        electronic_address:
          anyOf:
            - type: string
              maxLength: 60
            - type: 'null'
          title: Electronic Address
          description: Peppol electronic address. Companies only.
        is_customer:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Customer
          description: Whether it is a customer. Companies only.
        is_supplier:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Supplier
          description: Whether it is a supplier. Companies only.
        first_name:
          anyOf:
            - type: string
              maxLength: 245
              minLength: 1
            - type: 'null'
          title: First Name
          description: First name. Contacts only.
        last_name:
          anyOf:
            - type: string
              maxLength: 245
            - type: 'null'
          title: Last Name
          description: Last name. Contacts only.
      additionalProperties: false
      type: object
      title: RelationUpdate
      description: >-
        The editable part of a relation. Every field is optional: only the ones
        actually

        present in the request body are applied, so omitting a field leaves it
        untouched.


        Unlike create this is a single model, because `type` is not editable — a
        relation cannot

        move from RELCOMPANIES to RELCONTACTS. It therefore declares the fields
        of **both** types,

        and one that does not apply to the relation being updated is refused
        with

        `field_not_editable`. A request that breaks a rule changes nothing at
        all.


        Sending `null` **clears** a field, except for the ones create makes
        mandatory (`name` on

        a company, `first_name` on a contact): the update endpoint must not be
        able to produce a

        relation the create endpoint would have refused.
    CompanyRelationOut:
      properties:
        id:
          type: string
          title: Id
          description: Opaque unique identifier of the relation.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Display name. Company name for `company`, full name for `contact`.
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          description: Primary email address.
        phone:
          anyOf:
            - type: string
            - type: 'null'
          title: Phone
          description: Phone number.
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
          description: Preferred language, one of ['fr', 'en', 'nl', 'de'].
        address:
          anyOf:
            - $ref: '#/components/schemas/AddressOut'
            - type: 'null'
          description: Postal address, if known.
        type:
          type: string
          const: company
          title: Type
          description: Relation type, always `company` here.
        vat:
          anyOf:
            - type: string
            - type: 'null'
          title: Vat
          description: VAT number, prefixed with the ISO country code.
        identifier:
          anyOf:
            - type: string
            - type: 'null'
          title: Identifier
          description: Legal registration / party identifier.
        electronic_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Electronic Address
          description: Electronic address used to send invoices over Peppol.
        is_customer:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Customer
          description: '`true` if this company is a customer.'
        is_supplier:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Supplier
          description: '`true` if this company is a supplier.'
      additionalProperties: true
      type: object
      required:
        - id
        - type
      title: CompanyRelationOut
      description: >-
        A business third party. Carries the fields an individual has no
        equivalent of

        (`vat`, `identifier`, `electronic_address`, `is_customer`,
        `is_supplier`), and none of

        the contact-only ones — `first_name`/`last_name` are simply absent from
        the response.
    ContactRelationOut:
      properties:
        id:
          type: string
          title: Id
          description: Opaque unique identifier of the relation.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Display name. Company name for `company`, full name for `contact`.
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          description: Primary email address.
        phone:
          anyOf:
            - type: string
            - type: 'null'
          title: Phone
          description: Phone number.
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
          description: Preferred language, one of ['fr', 'en', 'nl', 'de'].
        address:
          anyOf:
            - $ref: '#/components/schemas/AddressOut'
            - type: 'null'
          description: Postal address, if known.
        type:
          type: string
          const: contact
          title: Type
          description: Relation type, always `contact` here.
        first_name:
          anyOf:
            - type: string
            - type: 'null'
          title: First Name
          description: First name.
        last_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Name
          description: Last name.
      additionalProperties: true
      type: object
      required:
        - id
        - type
      title: ContactRelationOut
      description: >-
        An individual. `name` is derived from `last_name` + `first_name` and is
        read-only;

        the company-only fields (`vat`, `identifier`, `electronic_address`,
        `is_customer`,

        `is_supplier`) are absent from the response.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AddressUpdate:
      properties:
        country_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Country Code
          description: must be an ISO 3166-1 alpha-2 country code, e.g. 'BE'.
        street:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Street
          description: Street name.
        street_number:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Street Number
          description: Street/house number.
        street2:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Street2
          description: Additional address line.
        postal_code:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Postal Code
          description: Postal/ZIP code.
        city:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: City
          description: City.
        province:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Province
          description: 'Free text: province, state or region.'
      additionalProperties: false
      type: object
      title: AddressUpdate
      description: >-
        The address fields to change. Unlike the rest of the body this is
        **merged** into the

        stored address: only the keys actually present are overwritten, the
        others keep their

        value. That is what makes it possible to fix a postal code without
        resending the country.


        The two address rules are checked on the **result** of that merge, so
        they hold whether

        the value comes from the request or from what was already stored:
        `country_code` can never

        end up empty, and `street_number` can never be set without a `street`.
    AddressOut:
      properties:
        street:
          anyOf:
            - type: string
            - type: 'null'
          title: Street
          description: Street name.
        street_number:
          anyOf:
            - type: string
            - type: 'null'
          title: Street Number
          description: Street/house number.
        street2:
          anyOf:
            - type: string
            - type: 'null'
          title: Street2
          description: Additional address line.
        postal_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Postal Code
          description: Postal/ZIP code.
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
          description: City.
        province:
          anyOf:
            - type: string
            - type: 'null'
          title: Province
          description: Province, state or region.
        country_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Country Code
          description: ISO 3166-1 alpha-2 country code (e.g. `BE`).
      type: object
      title: AddressOut
      description: >-
        Postal address of a relation. The object itself is `null` when none is
        stored.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````