# Generate object from a record (as workspace)

- Operation ID: `generateObjectForProfile`
- HTTP method: `POST`
- Path: `/brickworks/v1/schemas/{SchemaIdentifier}/records/{RecordIdentifier}/generate/by/{IdentifierType}`
- [Human-readable API reference](https://hub.synerise.com/api-reference/brickworks#tag/Brickworks:-Content-generation/operation/generateObjectForProfile)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /brickworks/v1/schemas/{SchemaIdentifier}/records/{RecordIdentifier}/generate/by/{IdentifierType}:
    post:
      tags:
        - "Brickworks: Content generation"
      summary: Generate object from a record (as workspace)
      description: |
        Generate content from the latest **published version of a record** by processing Jinjava inserts and requests to external sources. Profile data (if needed, for example for Jinjava) is retrieved automatically from the profile declared in the request.

        The system looks for values to generate in the following order:

          1. Values in the `fieldContext` object (used by recommendations and relations).
          1. Values saved in the record.
          2. Values from the `default` object in the schema.  
            This is available for all field types.  
          3. Default values nested in the `properties` of a field in the schema.  
            This is available for some complex field types.  


        The content is always generated according to the latest version of a schema:
          - If fields were deleted from the schema, but they still exist in the record, they are ignored.
          - If fields were added to the schema and they don't exist in the record, their default values are added. If there are no default values, the fields are ignored.

        Some data is cached:
        - profile data (even if the profile is updated)
        - responses from external sources  
        For details, see the [User Guide](https://hub.synerise.com/docs/assets/brickworks/limits).


        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>

        **API key permission required:** `BRICKWORKS_RECORDS_READ`

        **User role permission required:** `assets_brickworks: read`
      operationId: generateObjectForProfile
      security:
        - JWT: []
      parameters:
        - name: SchemaIdentifier
          in: path
          required: true
          description: Schema identifier - can be a UUID (SchemaId) or a human-readable string (Schema AppId/API name, 3-25 characters)
          schema:
            oneOf:
              - type: string
                format: uuid
                title: Schema UUID
              - type: string
                minLength: 3
                maxLength: 25
                pattern: ^(?!__)(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)[\w\-]+$
                title: Schema AppId
          examples:
            uuid:
              value: 550e8400-e29b-41d4-a716-446655440000
              summary: Schema UUID
            appId:
              value: my_schema_app_id
              summary: Schema AppId (API name)
        - name: RecordIdentifier
          in: path
          required: true
          description: Record identifier - can be a UUID (RecordId) or a human-readable slug (RecordSlug, 6-40 characters)
          schema:
            oneOf:
              - type: string
                format: uuid
                title: Record UUID
              - type: string
                minLength: 6
                maxLength: 40
                pattern: ^(?!__)(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)[\w\-]+$
                title: Record slug
          examples:
            uuid:
              value: f6ce33ee-bdf2-4a23-87be-07de936ceeab
              summary: Record UUID
            slug:
              value: my-record-slug
              summary: Record slug
        - name: IdentifierType
          in: path
          required: true
          description: Profile identifier type
          schema:
            type: string
            enum:
              - id
              - uuid
              - email
              - custom_identify
      requestBody:
        description: Object generation request
        content:
          application/json:
            schema:
              type: object
              x-class-name: GenerateRequest
              x-interface-name-ts: GenerateRequest
              required:
                - identifierValue
              properties:
                identifierValue:
                  type: string
                  description: Value of the profile identifier selected in `identifierType` (profile ID is sent as a string)
                context:
                  type: object
                  x-class-name: Context
                  x-interface-name-ts: Context
                  description: Additional context parameters. You can use these parameters in Jinjava fields by calling `{{ context.keyName }}`. The value will be printed as a string.
                  additionalProperties:
                    description: In Jinjava, you can retrieve the value of a key from this object by `{{ context.keyName }}`
                fieldContext:
                  type: object
                  x-class-name: FieldContext
                  x-interface-name-ts: FieldContext
                  description: Additional context parameters used in recommendation and relation fields.
                  additionalProperties:
                    type: object
                    x-class-name: FieldContextItem
                    x-interface-name-ts: FieldContextItem
                    description: The names of the objects correspond to the names of the fields where the object's data is used
                    additionalProperties: true
                    example:
                      page: 1
                      limit: 10
                      itemId: item-123
                      additionalFilters: custom filter value
      responses:
        "200":
          description: Processed content of a record
          content:
            application/json:
              schema:
                type: object
                x-class-name: GeneratedObject
                x-interface-name-ts: GeneratedObject
                description: Processed content of a record
                properties:
                  __slug:
                    type: string
                    minLength: 6
                    maxLength: 40
                    pattern: ^([a-zA-Z0-9\-]|_[a-zA-Z0-9\-])[\w\-]*
                    description: |
                      Unique (within a schema) identifier of a record. Can't be a UUID.

                      In singleton-type schemas, use the schema's `appId` or `id` in place of record identifiers for generating content.
                  __recordVersion:
                    type: number
                    format: int32
                    description: |
                      Identifier of the record version. 
                      - In simple schemas, this is always `1`
                      - In versioned schemas, the versions start with `1` on creation and are increased by 1 when you create a new draft. Publishing from a draft does NOT increase the version number.
                  __publishedAt:
                    type: string
                    format: date-time
                    description: Record publishing time
                  __updatedAt:
                    type: string
                    format: date-time
                    description: Last record update time
                  __schemaId:
                    type: string
                    format: uuid
                    description: Unique ID of the schema, generated automatically.
                  __id:
                    type: string
                    format: uuid
                    description: |
                      Unique identifier of a record, generated by the system. Can't be changed.

                      This identifier is common to all versions of the record, even when the slug changes.

                      In singleton-type schemas, use the schema's `appId` or `id` in place of record identifiers for generating content.
                  __schemaVersion:
                    type: integer
                    format: int32
                    description: Schema version ID. For simple schemas, this is always `1`. When a schema is updated, the ID increases by 1.
                  __createdAt:
                    type: string
                    format: date-time
                    description: Record creation time
                  __matchedAudience:
                    type: boolean
                    description: |
                      Indicates whether the client matched the audience defined on the schema. `true` when the client belongs to the target audience (or when no audience is defined), `false` when the client does not match the top-level schema audience.
                  __unmatchedAudienceRelations:
                    type: array
                    description: |
                      List of relation field names whose referenced schemas have an audience that the client did not match. These fields are returned as `null` in the response. Only present when at least one relation is audience-restricted for the given client.
                    items:
                      type: string
                  __logs:
                    description: |
                      Lambdas transformer user logs content, available only in preview mode
                    type: array
                    items:
                      type: object
                      properties:
                        level:
                          type: string
                        message:
                          type: string
                      required:
                        - level
                        - message
                additionalProperties: true
                example:
                  __slug: my-record-slug
                  __recordVersion: 1
                  __publishedAt: 2024-01-15T10:30:00Z
                  __updatedAt: 2024-01-15T10:30:00Z
                  __schemaId: 550e8400-e29b-41d4-a716-446655440000
                  __id: 550e8400-e29b-41d4-a716-446655440001
                  __schemaVersion: 1
                  __createdAt: 2024-01-15T10:30:00Z
                  customStringField: string value
                  customNumberField: 123.45
                  customBooleanField: true
                  customDateField: 2024-01-15
                  customArrayField:
                    - item1
                    - item2
                  customObjectField:
                    nestedKey: nestedValue
                  __matchedAudience: true
                  __unmatchedAudienceRelations:
                    - deniedRefField
        "400":
          description: Incorrect request (malformed JSON, wrong parameters, etc.). See error message for details.
          content:
            application/json:
              schema:
                type: object
                x-class-name: ObjectsError
                x-interface-name-ts: ObjectsError
                required:
                  - httpStatus
                  - errorCode
                  - timestamp
                  - message
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  httpStatus:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
                  traceId:
                    type: string
                    description: Unique identifier of the request, useful for tracing logs
                  errors:
                    type: array
                    items:
                      $ref: "#/components/schemas/brickworks-service-ObjectsError"
                  source:
                    type: object
                    x-class-name: ObjectErrorSource
                    x-interface-name-ts: ObjectErrorSource
                    required:
                      - pointer
                    properties:
                      pointer:
                        type: string
                        description: JSON Pointer for invalid body path
                      value:
                        type: string
                        description: Value that caused the validation error
                  details:
                    type: object
                    x-class-name: ObjectsErrorDetails
                    x-interface-name-ts: ObjectsErrorDetails
                    additionalProperties:
                      type: object
                    description: Additional structured error information
                  field:
                    type: string
                    description: Name of the field that caused the error
        "401":
          description: "Unauthorized: wrong consumer scope; token missing/expired/invalid; invalid API key; etc. See error message for details."
          content:
            application/json:
              schema:
                type: object
                x-class-name: GatewayError
                x-interface-name-ts: GatewayError
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  message:
                    type: string
                    description: Description of the problem
        "403":
          description: Forbidden; insufficient permissions. See error message for details.
          content:
            application/json:
              schema:
                type: object
                x-class-name: GatewayError
                x-interface-name-ts: GatewayError
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  message:
                    type: string
                    description: Description of the problem
        "404":
          description: Resource not found. See error message for details.
          content:
            application/json:
              schema:
                type: object
                x-class-name: ObjectsError
                x-interface-name-ts: ObjectsError
                required:
                  - httpStatus
                  - errorCode
                  - timestamp
                  - message
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  httpStatus:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
                  traceId:
                    type: string
                    description: Unique identifier of the request, useful for tracing logs
                  errors:
                    type: array
                    items:
                      $ref: "#/components/schemas/brickworks-service-ObjectsError"
                  source:
                    type: object
                    x-class-name: ObjectErrorSource
                    x-interface-name-ts: ObjectErrorSource
                    required:
                      - pointer
                    properties:
                      pointer:
                        type: string
                        description: JSON Pointer for invalid body path
                      value:
                        type: string
                        description: Value that caused the validation error
                  details:
                    type: object
                    x-class-name: ObjectsErrorDetails
                    x-interface-name-ts: ObjectsErrorDetails
                    additionalProperties:
                      type: object
                    description: Additional structured error information
                  field:
                    type: string
                    description: Name of the field that caused the error
        "409":
          description: The request could not be completed due to a conflict with the current state of the resource. See error message for details.
          content:
            application/json:
              schema:
                type: object
                x-class-name: ObjectsError
                x-interface-name-ts: ObjectsError
                required:
                  - httpStatus
                  - errorCode
                  - timestamp
                  - message
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  httpStatus:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
                  traceId:
                    type: string
                    description: Unique identifier of the request, useful for tracing logs
                  errors:
                    type: array
                    items:
                      $ref: "#/components/schemas/brickworks-service-ObjectsError"
                  source:
                    type: object
                    x-class-name: ObjectErrorSource
                    x-interface-name-ts: ObjectErrorSource
                    required:
                      - pointer
                    properties:
                      pointer:
                        type: string
                        description: JSON Pointer for invalid body path
                      value:
                        type: string
                        description: Value that caused the validation error
                  details:
                    type: object
                    x-class-name: ObjectsErrorDetails
                    x-interface-name-ts: ObjectsErrorDetails
                    additionalProperties:
                      type: object
                    description: Additional structured error information
                  field:
                    type: string
                    description: Name of the field that caused the error
        "422":
          description: The request was well-formed but could not be processed due to semantic or domain-related constraints. See error message for details.
          content:
            application/json:
              schema:
                type: object
                x-class-name: ObjectsError
                x-interface-name-ts: ObjectsError
                required:
                  - httpStatus
                  - errorCode
                  - timestamp
                  - message
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  httpStatus:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
                  traceId:
                    type: string
                    description: Unique identifier of the request, useful for tracing logs
                  errors:
                    type: array
                    items:
                      $ref: "#/components/schemas/brickworks-service-ObjectsError"
                  source:
                    type: object
                    x-class-name: ObjectErrorSource
                    x-interface-name-ts: ObjectErrorSource
                    required:
                      - pointer
                    properties:
                      pointer:
                        type: string
                        description: JSON Pointer for invalid body path
                      value:
                        type: string
                        description: Value that caused the validation error
                  details:
                    type: object
                    x-class-name: ObjectsErrorDetails
                    x-interface-name-ts: ObjectsErrorDetails
                    additionalProperties:
                      type: object
                    description: Additional structured error information
                  field:
                    type: string
                    description: Name of the field that caused the error
        "500":
          description: See error message for details.
          content:
            application/json:
              schema:
                type: object
                x-class-name: ObjectsError
                x-interface-name-ts: ObjectsError
                required:
                  - httpStatus
                  - errorCode
                  - timestamp
                  - message
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  httpStatus:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
                  traceId:
                    type: string
                    description: Unique identifier of the request, useful for tracing logs
                  errors:
                    type: array
                    items:
                      $ref: "#/components/schemas/brickworks-service-ObjectsError"
                  source:
                    type: object
                    x-class-name: ObjectErrorSource
                    x-interface-name-ts: ObjectErrorSource
                    required:
                      - pointer
                    properties:
                      pointer:
                        type: string
                        description: JSON Pointer for invalid body path
                      value:
                        type: string
                        description: Value that caused the validation error
                  details:
                    type: object
                    x-class-name: ObjectsErrorDetails
                    x-interface-name-ts: ObjectsErrorDetails
                    additionalProperties:
                      type: object
                    description: Additional structured error information
                  field:
                    type: string
                    description: Name of the field that caused the error
      x-snr-doc-urls:
        - /api-reference/brickworks#tag/Brickworks:-Content-generation/operation/generateObjectForProfile
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: "Brickworks: Content generation"
components:
  schemas:
    brickworks-service-ObjectsError:
      type: object
      x-class-name: ObjectsError
      x-interface-name-ts: ObjectsError
      required:
        - httpStatus
        - errorCode
        - timestamp
        - message
      properties:
        timestamp:
          type: string
          format: date-time
          description: Time when the error occurred
        errorCode:
          type: string
          description: |
            Code of the error, needed for troubleshooting

            See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
        httpStatus:
          type: integer
          description: Error's HTTP status code
        message:
          type: string
          description: Description of the problem
        traceId:
          type: string
          description: Unique identifier of the request, useful for tracing logs
        errors:
          type: array
          items:
            $ref: "#/components/schemas/brickworks-service-ObjectsError"
        source:
          type: object
          x-class-name: ObjectErrorSource
          x-interface-name-ts: ObjectErrorSource
          required:
            - pointer
          properties:
            pointer:
              type: string
              description: JSON Pointer for invalid body path
            value:
              type: string
              description: Value that caused the validation error
        details:
          type: object
          x-class-name: ObjectsErrorDetails
          x-interface-name-ts: ObjectsErrorDetails
          additionalProperties:
            type: object
          description: Additional structured error information
        field:
          type: string
          description: Name of the field that caused the error
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
