openapi: 3.2.0 info: title: Hmcts Subscription API version: 1.0.0 contact: name: HMCTS API Marketplace email: no-reply@hmcts.com license: name: MIT url: https://opensource.org/licenses/MIT description: 'Operations tagged Subscription across 2 of this provider''s published API definitions: api-cp-crime-hearing-results-document-subscription-openapi-spec.yml, hmcts-crime-hearing-results-document-subscription-openapi.yml. Each path carries the servers of the definition it was published in.' servers: - description: Crime Hearing Results Document Subscription API url: https://api-cp-crime-hearing-results-document-subscription.net/{version} variables: version: default: 1.0.0 description: API version; matches the spec info.version security: - bearerAuth: [] subscriptionKey: [] tags: - name: Subscription paths: /event-types: get: summary: Get list of valid event types for subscription service description: Returns list of valid event types for subscription service operationId: GetEventTypes tags: - Subscription responses: '200': description: Event types content: application/json: schema: $ref: '#/components/schemas/EventTypeResponse' examples: Event-Types Example: $ref: '#/components/examples/EventTypesResponse' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '401': description: Unauthorized - missing or invalid authentication credentials headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '403': description: Forbidden - valid subscription key required but not subscribed to this API headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' servers: - description: Crime Hearing Results Document Subscription API url: https://api-cp-crime-hearing-results-document-subscription.net/{version} variables: version: default: 1.0.0 description: API version; matches the spec info.version /client-subscriptions: post: summary: Create a new client subscription description: Creates a new client subscription with the specified callback URL. Events will be sent to the provided callback URL via callback. operationId: createClientSubscription tags: - Subscription parameters: - $ref: '#/components/parameters/XCorrelationId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ClientSubscriptionRequest' examples: createSubscription: $ref: '#/components/examples/createSubscriptionRequest' responses: '201': description: Subscription created successfully content: application/json: examples: createSubscription: $ref: '#/components/examples/createSubscriptionResponse' schema: $ref: '#/components/schemas/ClientSubscription' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '400': description: Invalid request payload content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: createSubscriptionError: $ref: '#/components/examples/createSubscriptionError' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '401': description: Unauthorized - missing or invalid authentication credentials headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '403': description: Forbidden - valid subscription key required but not subscribed to this API headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' callbacks: onEvent: '{$request.body#/notificationEndpoint/callbackUrl}': post: description: Event notification sent to the subscribed callback URL parameters: - $ref: '#/components/parameters/XCorrelationId' - name: X-Key-Id in: header required: true description: Identifier of the key used to sign this callback. Matches the keyId issued when the subscription was created. schema: type: string example: kid-v1-b41a48b7-a2a1-45f1-b562-1358f141ddb2 - name: X-Signature in: header required: true description: HMAC-SHA256 signature of the callback request using the subscription's shared secret. The secret is returned once at subscription creation. schema: type: string example: base64-encoded-signature requestBody: description: Event payload containing defendant and case information content: application/json: schema: $ref: '#/components/schemas/EventNotificationPayload' responses: '202': description: 'Your server implementation should return this HTTP status code if the event was received successfully ' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '400': description: Bad request - the event payload was invalid servers: - description: Crime Hearing Results Document Subscription API url: https://api-cp-crime-hearing-results-document-subscription.net/{version} variables: version: default: 1.0.0 description: API version; matches the spec info.version /client-subscriptions/{clientSubscriptionId}: get: summary: Retrieve a client subscription by ID description: Returns the subscription matching the given clientSubscriptionId. operationId: getClientSubscription tags: - Subscription parameters: - name: clientSubscriptionId in: path required: true schema: type: string format: uuid example: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 - $ref: '#/components/parameters/XCorrelationId' responses: '200': description: Subscription object headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' content: application/json: examples: getSubscriptionResponse: $ref: '#/components/examples/getSubscriptionResponse' schema: $ref: '#/components/schemas/ClientSubscription' '404': description: Subscription not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getSubscriptionError: $ref: '#/components/examples/getSubscriptionError' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '401': description: Unauthorized - missing or invalid authentication credentials headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '403': description: Forbidden - valid subscription key required but not subscribed to this API headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' put: summary: Strict update of a client subscription description: Caller must supply *all* updatable fields. operationId: updateClientSubscription tags: - Subscription parameters: - name: clientSubscriptionId in: path required: true example: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 schema: type: string format: uuid - $ref: '#/components/parameters/XCorrelationId' requestBody: required: true content: application/json: examples: updateSubscription: $ref: '#/components/examples/updateSubscription' schema: $ref: '#/components/schemas/ClientSubscriptionRequest' responses: '200': description: Subscription updated content: application/json: examples: updatedSubscriptionResponse: $ref: '#/components/examples/updatedSubscriptionResponse' schema: $ref: '#/components/schemas/ClientSubscription' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '400': description: Invalid request headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '404': description: Subscription not found headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '401': description: Unauthorized - missing or invalid authentication credentials headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '403': description: Forbidden - valid subscription key required but not subscribed to this API headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' delete: summary: Delete a subscription by ID description: Deletes the subscription identified by clientSubscriptionId. operationId: deleteClientSubscription tags: - Subscription parameters: - name: clientSubscriptionId in: path required: true example: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 schema: type: string format: uuid - $ref: '#/components/parameters/XCorrelationId' responses: '204': description: Deleted successfully headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '404': description: Subscription not found headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '401': description: Unauthorized - missing or invalid authentication credentials headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '403': description: Forbidden - valid subscription key required but not subscribed to this API headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' servers: - description: Crime Hearing Results Document Subscription API url: https://api-cp-crime-hearing-results-document-subscription.net/{version} variables: version: default: 1.0.0 description: API version; matches the spec info.version /client-subscriptions/{clientSubscriptionId}/secret/rotate: post: summary: Rotate the HMAC signing secret for a subscription description: Issues a new HMAC secret for the specified subscription. The new secret is returned once and cannot be retrieved again. operationId: rotateClientSubscriptionSecret tags: - Subscription parameters: - name: clientSubscriptionId in: path required: true schema: type: string format: uuid example: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 - $ref: '#/components/parameters/XCorrelationId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RotateSecretRequest' examples: rotateSecret: $ref: '#/components/examples/rotateSecretRequest' responses: '200': description: Secret rotated successfully. The new secret is returned once and cannot be retrieved again. content: application/json: schema: $ref: '#/components/schemas/HmacCredentials' examples: rotateSecretResponse: $ref: '#/components/examples/rotateSecretResponse' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '400': description: Invalid request — missing or malformed keyId content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '401': description: Unauthorized - missing or invalid authentication credentials headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '403': description: Forbidden — the subscription does not belong to the calling client headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' '404': description: Not found — the keyId does not match any known key for this subscription content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' headers: X-Correlation-Id: $ref: '#/components/headers/XCorrelationId' servers: - description: Crime Hearing Results Document Subscription API url: https://api-cp-crime-hearing-results-document-subscription.net/{version} variables: version: default: 1.0.0 description: API version; matches the spec info.version components: schemas: NotificationEndpoint: type: object required: - callbackUrl properties: callbackUrl: type: string pattern: ^https://.*$ description: The location where event data will be sent. Event notifications will be POSTed to this URL with EventNotificationPayload in the request body. RotateSecretRequest: type: object required: - keyId properties: keyId: type: string description: Identifier of the current key to rotate example: kid-v1-b41a48b7-a2a1-45f1-b562-1358f141ddb2 ErrorResponse: type: object required: - error - message properties: error: type: string message: type: string ClientSubscription: type: object required: - clientSubscriptionId - notificationEndpoint - eventTypes - createdAt properties: clientSubscriptionId: type: string format: uuid notificationEndpoint: $ref: '#/components/schemas/NotificationEndpoint' eventTypes: type: array items: $ref: '#/components/schemas/EventType' createdAt: type: string format: date-time updatedAt: type: string format: date-time hmac: $ref: '#/components/schemas/HmacCredentials' ClientSubscriptionRequest: type: object required: - notificationEndpoint - eventTypes properties: notificationEndpoint: $ref: '#/components/schemas/NotificationEndpoint' eventTypes: type: array minItems: 1 items: $ref: '#/components/schemas/EventType' HmacCredentials: type: object description: HMAC credentials issued at subscription creation for signing outbound callbacks. properties: keyId: type: string description: Identifier for the shared secret used to sign outbound callbacks for this subscription example: kid-v1-b41a48b7-a2a1-45f1-b562-1358f141ddb2 secret: type: string writeOnly: true description: Base64-encoded shared secret used to sign outbound callbacks for this subscription. Returned in the create subscription response. Not returned by subsequent GET operations. example: example-base64-encoded-secret EventTypeResponse: type: object properties: events: type: array items: $ref: '#/components/schemas/EventTypePayload' EventNotificationPayload: type: object description: Callback payload delivered to the subscriber. required: - eventType - hearingId - cases - masterDefendantId - documentId - documentGeneratedTimestamp - prisonEmailAddress properties: hearingEventId: type: string format: uuid description: Per-subscriber identifier for this notification, received in the callback. example: a1b2c3d4-e5f6-7890-abcd-ef1234567890 eventType: description: Type of the event that triggered this notification example: PRISON_COURT_REGISTER_GENERATED $ref: '#/components/schemas/EventType' hearingId: type: string format: uuid description: Unique identifier of the hearing that produced the result document example: 7f3b1c2d-4e5a-6789-abcd-ef0123456789 masterDefendantId: type: string format: uuid description: Unique identifier for the master defendant example: 550e8400-e29b-41d4-a716-446655440000 documentId: type: string format: uuid description: Unique identifier of the document used by consumers while fetching it example: 123e4567-e89b-12d3-a456-426614174000 documentGeneratedTimestamp: type: string format: date-time description: Document generation timestamp example: '2024-01-15T10:30:00Z' cases: type: array minItems: 1 description: List of cases associated with the defendant items: type: object required: - urn properties: urn: type: string description: Case URN associated with the defendant example: CT981234123 prisonEmailAddress: type: string format: email description: Email address of the prison example: prison@example.com EventType: type: string description: "Possible values:\n - PRISON_COURT_REGISTER_GENERATED\n - WEE_Layout5\n - NEE_DetentionOnRecommendationForDeportation\n - OEE_MedicalRemandAdditionalDetails\n - WEE_RemandAfterBailAppealByProsecutor\n - WEE_CustodialSentence\n - WEE_CustodialSentenceWitness\n - WEE_CommittalToCrownCourtForConsiderationOfTheQuestionOfBailOnAChargeOfMurder\n - WEE_CommittalToCrownCourtForSentence\n - WEE_SendingToCrownCourtForTrial\n - OEE_BailAppealEndOfCustody\n - WEE_CommitmentPendingTransferToServiceCustody\n - WEE_NonPaymentOfMoneyOwedCivilDebt\n - WEE_CustodyWarrantOnDischargeOfExtraditionPendingAppeal\n - WEE_CustodyWarrantOnDischargeOfExtraditionPendingAppealPart2\n - WEE_CustodyWarrantOnExtradition\n - WEE_CustodyWarrantOnExtraditionCategory2Territory\n - WEE_CustodyWarrantOnExtraditionWithConsent\n - WEE_CustodyWarrantOnExtraditionWithBailDirection\n - WEE_CustodyWarrantOnExtraditionWithBailDirectionWithConsent\n - WEE_CustodyWarrantOnExtraditionWithBailDirectionCategory2Territory\n - WEE_CustodyWarrantSendingToSecretaryOfStateCategory2Territory\n - WEE_CustodyWarrantSendingToSecretaryOfStateOnConsentCategory2Territory\n - WEE_CustodyWarrantWithBailDirectionOnDischargeOfExtraditionPendingAppeal\n - WEE_CustodyWarrantWithBailDirectionOnDischargeOfExtraditionPendingAppealPart2\n - WEE_CustodyWarrantWithBailDirectionSendingToSecretaryOfStateCategory2Territory\n - WEE_CustodyWarrantWithBailDirectionSendingToSecretaryOfStateOnConsentCategory2Territory\n - WEE_ExtraditionRemandAfterBailAppealByProsecutor\n - WEE_ExtraditionSupplementToCustodyWarrant\n - OBE_TerminationOfFootballBanning\n - OBE_ChangeOfFootballBanning\n - NEE_FootballBanning\n - WEE_Remand\n - WXE_RemandWarrantYouthDetentionAccommodation\n - OXE_DetentionAndTraining\n - WEE_InjunctionDetention\n - OPE_SupervisionOnBreachOfDetentionAndTraining\n - WEE_CommittalToCrownCourtAuthorityToHoldInYouthDetentionAccommodation\n - WEE_Detention\n - WEE_DetentionInYouthDetentionAccommodationBreach\n - WEE_SendingToCrownCourtAuthorityToHoldInYouthDetentionAccommodation\n" EventTypePayload: type: object properties: eventName: type: string displayName: type: string category: type: string headers: XCorrelationId: description: Correlation identifier for this request/response, used for end-to-end tracing. schema: type: string format: uuid example: bf931a90-3e3f-4e8e-a8e4-a4ca9ac07830 examples: updatedSubscriptionResponse: summary: Example update subscription response value: clientSubscriptionId: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 notificationEndpoint: callbackUrl: https://client.example.com/new-hook eventTypes: - PRISON_COURT_REGISTER_GENERATED createdAt: '2025-01-01T10:00:00Z' updatedAt: '2025-01-10T09:15:00Z' createSubscriptionRequest: summary: Example subscription creation request value: notificationEndpoint: callbackUrl: https://client.example.com/events eventTypes: - PRISON_COURT_REGISTER_GENERATED updateSubscription: summary: Example update request value: notificationEndpoint: callbackUrl: https://client.example.com/new-hook eventTypes: - PRISON_COURT_REGISTER_GENERATED createSubscriptionError: summary: Example subscription creation error response value: error: invalid_request message: eventTypes must contain at least one value. rotateSecretResponse: summary: Example secret rotation response value: keyId: kid-v1-b41a48b7-a2a1-45f1-b562-1358f141ddb2 secret: new-example-base64-encoded-secret getSubscriptionError: summary: Example GET subscription error response value: error: not_found message: No subscription exists for ID aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44. createSubscriptionResponse: summary: Example subscription creation response value: clientSubscriptionId: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 notificationEndpoint: callbackUrl: https://client.example.com/events eventTypes: - PRISON_COURT_REGISTER_GENERATED hmac: keyId: kid-v1-b41a48b7-a2a1-45f1-b562-1358f141ddb2 secret: example-base64-encoded-secret createdAt: '2025-01-01T10:00:00Z' updatedAt: null getSubscriptionResponse: summary: Example GET subscription response value: clientSubscriptionId: aa12f3dd-4cc1-4da7-b9ea-552fa3b9bc44 notificationEndpoint: callbackUrl: https://client.example.com/events eventTypes: - PRISON_COURT_REGISTER_GENERATED createdAt: '2025-01-01T10:00:00Z' updatedAt: '2025-01-05T17:30:00Z' EventTypesResponse: summary: Example Event-Types response value: events: - eventName: PRISON_COURT_REGISTER_GENERATED displayName: Prison court register category: REGISTER - eventName: WEE_Layout5 displayName: Warrant Supplement category: WARRANT - eventName: NEE_DetentionOnRecommendationForDeportation displayName: Detention on Recommendation for Deportation category: NOTICE - eventName: OEE_MedicalRemandAdditionalDetails displayName: Medical Remand - Additional Details category: ORDER - eventName: WEE_RemandAfterBailAppealByProsecutor displayName: Remand Warrant After Bail Appeal by Prosecutor category: WARRANT - eventName: WEE_CustodialSentence displayName: Warrant for Custodial Sentence category: WARRANT - eventName: WEE_CustodialSentenceWitness displayName: Warrant for Custodial Sentence (Witness) category: WARRANT - eventName: WEE_CommittalToCrownCourtForConsiderationOfTheQuestionOfBailOnAChargeOfMurder displayName: Warrant of Committal to Crown Court for Consideration of the Question of Bail on a Charge of Murder category: WARRANT - eventName: WEE_CommittalToCrownCourtForSentence displayName: Warrant of Committal to Crown Court for Sentence category: WARRANT - eventName: WEE_SendingToCrownCourtForTrial displayName: Warrant of Sending to Crown Court for Trial category: WARRANT - eventName: OEE_BailAppealEndOfCustody displayName: Bail Appeal - End of Custody category: ORDER - eventName: WEE_CommitmentPendingTransferToServiceCustody displayName: Warrant of Commitment Pending Transfer to Service Custody category: WARRANT - eventName: WEE_NonPaymentOfMoneyOwedCivilDebt displayName: Warrant of Committal for Non-Payment of Money Owed Civil Debt category: WARRANT - eventName: WEE_CustodyWarrantOnDischargeOfExtraditionPendingAppeal displayName: Custody Warrant on Discharge of Extradition Pending Appeal category: WARRANT - eventName: WEE_CustodyWarrantOnDischargeOfExtraditionPendingAppealPart2 displayName: Custody Warrant on Discharge of Extradition Pending Appeal (Part 2) category: WARRANT - eventName: WEE_CustodyWarrantOnExtradition displayName: Custody Warrant on Extradition category: WARRANT - eventName: WEE_CustodyWarrantOnExtraditionCategory2Territory displayName: Custody Warrant on Extradition - Category 2 Territory category: WARRANT - eventName: WEE_CustodyWarrantOnExtraditionWithConsent displayName: Custody Warrant on Extradition (Part 1) category: WARRANT - eventName: WEE_CustodyWarrantOnExtraditionWithBailDirection displayName: Custody Warrant on Extradition (with Bail Direction) category: WARRANT - eventName: WEE_CustodyWarrantOnExtraditionWithBailDirectionWithConsent displayName: Custody Warrant on Extradition with Bail Direction category: WARRANT - eventName: WEE_CustodyWarrantOnExtraditionWithBailDirectionCategory2Territory displayName: Custody Warrant on Extradition (with Bail Direction) - Category 2 Territory category: WARRANT - eventName: WEE_CustodyWarrantSendingToSecretaryOfStateCategory2Territory displayName: Custody Warrant Sending to Secretary of State - Category 2 Territory category: WARRANT - eventName: WEE_CustodyWarrantSendingToSecretaryOfStateOnConsentCategory2Territory displayName: Custody Warrant Sending to Secretary of State on Consent - Category 2 Territory category: WARRANT - eventName: WEE_CustodyWarrantWithBailDirectionOnDischargeOfExtraditionPendingAppeal displayName: Custody Warrant with Bail Direction on Discharge of Extradition Pending Appeal category: WARRANT - eventName: WEE_CustodyWarrantWithBailDirectionOnDischargeOfExtraditionPendingAppealPart2 displayName: Custody Warrant with Bail Direction on Discharge of Extradition Pending Appeal (Part 2) category: WARRANT - eventName: WEE_CustodyWarrantWithBailDirectionSendingToSecretaryOfStateCategory2Territory displayName: Custody Warrant with Bail Direction Sending to Secretary of State - Category 2 Territory category: WARRANT - eventName: WEE_CustodyWarrantWithBailDirectionSendingToSecretaryOfStateOnConsentCategory2Territory displayName: Custody Warrant with Bail Direction Sending to Secretary of State on Consent - Category 2 Territory category: WARRANT - eventName: WEE_ExtraditionRemandAfterBailAppealByProsecutor displayName: Remand Warrant After Bail Appeal by Prosecutor - Extradition category: WARRANT - eventName: WEE_ExtraditionSupplementToCustodyWarrant displayName: Supplement to Custody Warrant on Extradition category: WARRANT - eventName: OBE_TerminationOfFootballBanning displayName: Application for Termination of Football Banning Order category: ORDER - eventName: OBE_ChangeOfFootballBanning displayName: Change of Football Banning Order category: ORDER - eventName: NEE_FootballBanning displayName: Notice of Football Banning Order category: NOTICE - eventName: WEE_Remand displayName: Remand Warrant category: WARRANT - eventName: WXE_RemandWarrantYouthDetentionAccommodation displayName: Remand Warrant - Youth Detention Accommodation category: WARRANT - eventName: OXE_DetentionAndTraining displayName: Detention and Training Order category: ORDER - eventName: WEE_InjunctionDetention displayName: Injunction Warrant of Detention category: WARRANT - eventName: OPE_SupervisionOnBreachOfDetentionAndTraining displayName: Supervision on Breach of Detention and Training Order category: ORDER - eventName: WEE_CommittalToCrownCourtAuthorityToHoldInYouthDetentionAccommodation displayName: Warrant of Committal to Crown Court - Authority to Hold in Youth Detention Accommodation category: WARRANT - eventName: WEE_Detention displayName: Warrant of Detention category: WARRANT - eventName: WEE_DetentionInYouthDetentionAccommodationBreach displayName: Warrant of Detention in Youth Detention Accommodation (Breach) category: WARRANT - eventName: WEE_SendingToCrownCourtAuthorityToHoldInYouthDetentionAccommodation displayName: Warrant of Sending to Crown Court - Authority to Hold in Youth Detention Accommodation category: WARRANT rotateSecretRequest: summary: Example secret rotation request value: keyId: kid-v1-b41a48b7-a2a1-45f1-b562-1358f141ddb2 parameters: XCorrelationId: name: X-Correlation-Id in: header required: false description: Optional correlation identifier for end-to-end tracing. schema: type: string format: uuid example: d679fd61-061f-4440-9623-36280f0807b7 securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT subscriptionKey: type: apiKey in: header name: Ocp-Apim-Subscription-Key description: Subscription key for API access x-refined-from: - api-cp-crime-hearing-results-document-subscription-openapi-spec.yml - hmcts-crime-hearing-results-document-subscription-openapi.yml