Create Webhook

This API allows the developer to create a new webhook subscription.

Swagger

			
swagger: '2.0'
info:
  x-ibm-name: orders
  title: Orders
  version: 1.0.0
schemes:
  - https
host: $(catalog.host)
basePath: /v1
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  oauth2:
    type: oauth2
    description: ''
    flow: accessCode
    authorizationUrl: 'https://<.........................>/fsc/oauth2/authorize'
    scopes:
      Fulfillment_Returns: ''
    tokenUrl: 'https://<.........................>/fsc/oauth2/token'
  Client_Secret:
    type: apiKey
    description: Enter Client Secret
    in: header
    name: X-IBM-Client-Secret
  Client_Id:
    type: apiKey
    in: header
    name: X-IBM-Client-Id
    description: Enter Client ID
security:
  - Client_Secret: []
    Client_Id: []
    oauth2:
      - Fulfillment_Returns
x-ibm-configuration:
  testable: true
  enforced: true
  phase: realized
paths:
  /services/webhook:
    post:
      responses:
        200:
          description: 200 OK
      parameters:
      - name: create_order_json_body
        required: true
        in: body
        schema:
          type: json
        description: ''
      - name: AccessToken
        type: string
        required: true
        in: header
        description: Enter Access Token, it is required header
      	summary: Create Webhook
      	description: This API allows the developer to create a new webhook subscription. 
 
   

Sample Request

         

{    
    "eventName": "Order_Shipped",
    "url": "https://yourcompany.com/webhook/callbackURL",
    "secret":"top_secret"
}

 
       

Sample Response

Success Response

         
{
     "requestIdentifier": "234234234234234",
     "transactionDate": "2018-09-20T15:12:54-05:00",
     "status": "success",
     "webhooks": [
      {
         "webhookId": "1111"
       }
]
}

      

Error Response

      
{
  "status": "error",
  "errors": [
    {
      "code": "ERR-SYS-0001",
      "description": "Your request cannot be processed due to a system error."
    }
  ]
}


      

OAuth 2.0

HTTP Headers Description
Authorization You must always provide the access token for authorization to access the API.

HTTP-Header       Value
Authorization       Bearer accessToken
Origin Origin URL.

HTTP-Header       Value
Origin                domain.com

Custom authentication

HTTP Headers Description
X-IBM-Client-Id You must always provide in the HTTP header your API portal application's client ID (X-IBM-Client-Id) to access the API.

HTTP-Header       Value
X-IBM-Client-Id     ************
X-IBM-Client-Secret You must always provide in the HTTP header your API portal application's client secret (X-IBM-Client-Secret) to access the API.

HTTP-Header       Value
X-IBM-Client-Secret     ************
AccessToken Application Access Token
Origin Origin URL.

HTTP-Header       Value
Origin                domain.com

Request Attribute

Parameter Data Type Description Required
eventName String The event name for which the developer subscribes to the Webhook callback. For example, if the developer is interested in the order shipped, the eventName should be Order_Shipped.
Valid Values: Order_Shipped, Order_PartiallyShipped.
Y
url String The callback URL. Y
Secret String If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-FDX-SC-Signature HTTPS header when a webhook event is sent. N

Response Attribute

Parameter Data Type Description
requestIdentifier String Request identifier
transactionDate String Transaction date/time
success String Status of the transaction
Valid Values:
true or false.
webhook[]    
webhookId String The webhook subscription ID that is just created.
errors[]    
code String Code associated with the error
description String Description of the error

HTTP Status Code

Code Description
200 OK - HTTP Response for successfully processed requests
400 Bad Request.
403 Forbidden
404 Not Found - Server couldn’t find anything matching request URI
500 Internal Server Error – Unable to process the request

Error Code

Code Description
ERR-SYS-0001 Your request cannot be processed due to a system error.
ERR-CMR-0001 Input data validation failed.
ERR-CMR-0002 Authentication Failed. Invalid Access Token.
ERR-CMR-0003 Missing mandatory fields.
ERR-WHK-0001 Event Name missing
ERR-WHK-0002 Invalid Event Name
ERR-WHK-0003 Callback URL missing
ERR-WHK-0004 Invalid Webhook ID
ERR-WHK-0005 Invalid status
ERR_WHK-0006 Webhook <webhookId> is already active
ERR-WHK-0007 Webhook <webhookId> is already inactive
ERR-WHK-0008 Webhook <webhookId> is not active.
ERR-WHK-0009 Webhook already exists for the event.