openapi: 3.0.0
paths:
  "/api/widget/{entityDid}/wallet/{walletDid}/credentials":
    get:
      operationId: listCredentials
      summary: List Credentials
      description: This endpoint is used to list available credentials (in draft or
        issued state).
      parameters:
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
        - name: schema
          required: false
          in: query
          description: Filter credentials by their credential schema
          schema:
            type: string
        - name: queryStates
          required: false
          in: query
          description: Filter by the credential state.
          schema:
            type: array
            items:
              type: string
              enum:
                - draft
                - issued
                - abandoned
        - name: queryMode
          required: false
          in: query
          description: Filter by ownership of the credential.
          schema:
            enum:
              - All
              - Presented
              - Held
            type: string
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Credentials"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
  "/api/widget/{entityDid}/wallet/{walletDid}/credential/{credentialDid}":
    get:
      operationId: getCredential
      summary: Get a Credential
      description: This endpoint is used to get detailed information about a
        credential (in draft or issued state).
      parameters:
        - name: credentialDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the credential.
          schema:
            type: string
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Credential"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
    put:
      operationId: updateCredential
      summary: Update Credential
      description: This endpoint is used for updating a credential meta and claims.
      parameters:
        - name: credentialDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the credential.
          schema:
            type: string
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CredentialUpdatePayload"
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CredentialUpdateResponse"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
    patch:
      operationId: patchCredential
      summary: Patch Credential
      description: This endpoint is used for patching a credential meta and claims.
      parameters:
        - name: credentialDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the credential.
          schema:
            type: string
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CredentialPatchPayload"
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CredentialUpdateResponse"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
    post:
      operationId: issueCredential
      summary: Issue Credential
      description: This endpoint is used for issuing a credential.
      parameters:
        - name: credentialDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the credential.
          schema:
            type: string
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
        - name: revision
          required: true
          in: query
          description: The revision number of the verifiable credential.
          schema:
            type: number
      responses:
        "201":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CredentialUpdateResponse"
        "400":
          description: Credential can't be created due to schema validation errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorsResponse"
        "409":
          description: Credential can't be issued due to claims validation errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorsResponse"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
  "/api/widget/{entityDid}/wallet/{walletDid}/credential":
    post:
      operationId: createCredential
      summary: Create a Credential
      description: This endpoint is used for creating a credential.
      parameters:
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CredentialCreatePayload"
      responses:
        "201":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CredentialCreateResponse"
        "400":
          description: Credential can't be created due to schema validation errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorsResponse"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
  "/api/widget/{entityDid}/wallet/{walletDid}/credential/{credentialDid}/schema":
    get:
      operationId: getCredentialSchema
      summary: Get Credential Schema
      description: This endpoint is used for obtaining the JSON Schema associated with
        the credential.
      parameters:
        - name: credentialDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the credential.
          schema:
            type: string
        - name: walletDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the wallet.
          schema:
            type: string
        - name: entityDid
          required: true
          in: path
          description: The DID (Decentralized Identifier) of the entity associated with
            the wallet.
          schema:
            type: string
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CredentialSchema"
        default:
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
      security:
        - ApiKeyAuth: []
info:
  title: Widget Backend API
  description: OpenAPI spec for Widget Backend API
  version: "1.0"
  contact: {}
tags: []
servers:
  - url: https://api.truvity.com
    description: Production service
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: X-API-KEY
      in: header
  schemas:
    Credentials:
      type: object
      properties:
        items:
          description: Array of credentials.
          type: array
          items:
            type: object
            properties:
              claims:
                description: A dictionary of claims for the credential. A claim is an assertion
                  made about a subject.
                type: object
                properties: {}
              meta:
                description: Additional metadata. Includes specific information such as the
                  holder, subject, expiration date, and other relevant details
                  for the credential.
                type: object
                properties:
                  id:
                    description: The DID (Decentralized Identifier) of the credential.
                    type: string
                  credentialSchemaId:
                    description: The $id of the credential schema.
                    type: string
                  expirationDate:
                    description: The date and time then the credential ceases to be valid.
                    type: string
                  holder:
                    description: A role an entity might perform by possessing one or more verifiable
                      credentials and generating presentations from them. A
                      holder is usually, but not always, a subject of the
                      verifiable credentials they are holding.
                    type: string
                  subject:
                    description: A thing about which claims are made.
                    type: string
                  issuanceMeta:
                    description: Metadata containing information related to the issuance process. It
                      includes specific information such as the issuer and
                      issuance date of the credential.
                    type: object
                    properties:
                      issuer:
                        description: A role an entity can perform by asserting claims about one or more
                          subjects, creating a verifiable credential from these
                          claims, and transmitting the verifiable credential to
                          a holder.
                        type: string
                      issuanceDate:
                        description: The date and time the credential becomes valid, which could be a
                          date and time in the future.
                        type: string
                    required:
                      - issuer
                      - issuanceDate
                required:
                  - id
                  - credentialSchemaId
              revision:
                description: The revision number of the credential.
                type: number
              state:
                description: Credential state.
                type: string
                enum:
                  - draft
                  - issued
                  - abandoned
            required:
              - claims
              - meta
              - revision
              - state
      required:
        - items
    ApiError:
      type: object
      properties:
        Code:
          description: The error code.
          type: string
        Message:
          description: The error message.
          type: string
      required:
        - Code
        - Message
    Credential:
      type: object
      properties:
        claims:
          description: A dictionary of claims for the credential. A claim is an assertion
            made about a subject.
          type: object
          properties: {}
        meta:
          description: Additional metadata. Includes specific information such as the
            holder, subject, expiration date, and other relevant details for the
            credential.
          type: object
          properties:
            id:
              description: The DID (Decentralized Identifier) of the credential.
              type: string
            credentialSchemaId:
              description: The $id of the credential schema.
              type: string
            expirationDate:
              description: The date and time then the credential ceases to be valid.
              type: string
            holder:
              description: A role an entity might perform by possessing one or more verifiable
                credentials and generating presentations from them. A holder is
                usually, but not always, a subject of the verifiable credentials
                they are holding.
              type: string
            subject:
              description: A thing about which claims are made.
              type: string
            issuanceMeta:
              description: Metadata containing information related to the issuance process. It
                includes specific information such as the issuer and issuance
                date of the credential.
              type: object
              properties:
                issuer:
                  description: A role an entity can perform by asserting claims about one or more
                    subjects, creating a verifiable credential from these
                    claims, and transmitting the verifiable credential to a
                    holder.
                  type: string
                issuanceDate:
                  description: The date and time the credential becomes valid, which could be a
                    date and time in the future.
                  type: string
              required:
                - issuer
                - issuanceDate
          required:
            - id
            - credentialSchemaId
        revision:
          description: The revision number of the credential.
          type: number
        state:
          description: Credential state.
          type: string
          enum:
            - draft
            - issued
            - abandoned
      required:
        - claims
        - meta
        - revision
        - state
    CredentialCreatePayload:
      type: object
      properties:
        jsonSchema:
          description: The JSON Schema associated with the credential.
          type: object
          properties: {}
      required:
        - jsonSchema
    CredentialCreateResponse:
      type: object
      properties:
        id:
          description: The DID (Decentralized Identifier) of the credential.
          type: string
        revision:
          description: The revision number of the credential.
          type: number
      required:
        - id
        - revision
    ValidationErrorsResponse:
      type: object
      properties:
        code:
          description: The error code.
          type: string
          enum:
            - ECREDENTIALSCHEMAVALIDATION
            - ECREDENTIALSCHEMAINVALID
        message:
          description: The error message.
          type: string
        errors:
          description: The list of errors.
          type: array
          items:
            type: object
            properties:
              keyword:
                description: The error code.
                type: string
              instancePath:
                description: The path where the error occurred.
                type: string
              message:
                description: The error message.
                type: string
            required:
              - keyword
              - instancePath
      required:
        - code
        - errors
    CredentialUpdatePayload:
      type: object
      properties:
        claims:
          description: The new claims that will replace the existing ones. A claim is an
            assertion made about a subject.
          type: object
          properties: {}
        meta:
          description: The new metadata information that will replace the existing one.
          type: object
          properties:
            holder:
              description: A role an entity might perform by possessing one or more verifiable
                credentials and generating presentations from them. A holder is
                usually, but not always, a subject of the verifiable credentials
                they are holding.
              type: string
            subject:
              description: A thing about which claims are made.
              type: string
            expirationDate:
              description: The date and time then the credential ceases to be valid.
              type: string
        revision:
          description: The incremented revision of the credential.
          type: number
      required:
        - claims
        - revision
    CredentialUpdateResponse:
      type: object
      properties:
        id:
          description: The DID (Decentralized Identifier) of the credential.
          type: string
        revision:
          description: The incremented revision of the credential.
          type: number
      required:
        - id
        - revision
    CredentialPatchPayload:
      type: object
      properties:
        update:
          description: The update operation that will merge existing claims or meta with
            the new ones.
          type: object
          properties:
            claims:
              description: The claims that will be merged with existing ones. A claim is an
                assertion made about a subject.
              type: object
              properties: {}
            meta:
              description: The metadata that will be merged with existing one.
              type: object
              properties:
                holder:
                  description: A role an entity might perform by possessing one or more verifiable
                    credentials and generating presentations from them. A holder
                    is usually, but not always, a subject of the verifiable
                    credentials they are holding.
                  type: string
                subject:
                  description: A thing about which claims are made.
                  type: string
                expirationDate:
                  description: The date and time then the credential ceases to be valid.
                  type: string
        remove:
          description: The remove operation that will remove from existing claims or meta
            the list or claims or meta provided.
          type: object
          properties:
            claims:
              description: The list of claims that will be removed from the existing ones. A
                claim is an assertion made about a subject.
              type: array
              items:
                type: string
            meta:
              description: The metadata fields that will be removed from the existing one.
              type: object
              properties:
                holder:
                  description: A role an entity might perform by possessing one or more verifiable
                    credentials and generating presentations from them. A holder
                    is usually, but not always, a subject of the verifiable
                    credentials they are holding.
                  type: boolean
                subject:
                  description: A thing about which claims are made.
                  type: boolean
                expirationDate:
                  description: The date and time then the credential ceases to be valid.
                  type: boolean
        revision:
          description: The incremented revision of the credential.
          type: number
      required:
        - revision
    CredentialSchema:
      description: The JSON Schema associated with the credential.
      type: object
      properties: {}

