openapi: 3.0.3
info:
title: Enabling crop loans on SAFAL - API Documentation
description: >-
API documentation for Safal portal, Beckn protocol server and Bank server
communication
version: 0.0.1
externalDocs:
description: Find out more about Konnect
url: 'https://github.com/Konnect-Agri'
paths:
/search:
post:
tags:
- search
summary: Search for the loan catalog
description: Search for the loan catalog
operationId: search
requestBody:
description: Search for the loan catalog
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- search
message:
type: object
properties:
intent:
type: object
properties:
tags:
type: object
properties:
block:
type: string
district:
type: string
bank_name:
type: string
required:
- context
- message
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
message:
type: object
properties:
catalog:
$ref: '#/components/schemas/Catalog'
required:
- catalog
required:
- context
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
error:
$ref: '#/components/schemas/Error'
required:
- context
/select:
post:
tags:
- select
summary: Select a loan product from a catalog
description: Select a loan product from a catalog
operationId: select
requestBody:
description: Select a loan product from a catalog
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- select
required:
- action
message:
type: object
properties:
order:
$ref: '#/components/schemas/SelectRequestObject'
required:
- order
required:
- context
- message
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
message:
$ref: '#/components/schemas/SelectResponseObject'
required:
- context
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
error:
$ref: '#/components/schemas/Error'
required:
- context
/authenticate:
post:
tags:
- authenticate
summary: Send membership number entered by the farmer to the bank’s portal for validation
operationId: authenticateFarmer
requestBody:
description: Validate farmer's membership number
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerAuthRequest'
required: true
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerAuthSuccess'
'400':
description: Invalid KCC / Aadhaar Number Supplied
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerAuthError'
/register:
post:
tags:
- register
summary: Register farmer
operationId: registerFarmer
requestBody:
description: Register farmer for new membership ID
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerRegRequest'
required: true
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerRegSuccess'
'400':
description: Invalid registration request
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerRegError'
/calculate:
post:
tags:
- calculate
summary: Send farmer's land and crop details to bank for NCL calculation
operationId: calculateNCL
requestBody:
description: Calculate farmers NCL
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerNCLRequest'
required: true
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerNCLSuccess'
'400':
description: Invalid KCC / Aadhaar Number Supplied
content:
application/json:
schema:
$ref: '#/components/schemas/FarmerNCLError'
/registerConsent:
post:
tags:
- Consent artifact request from Consumer
summary: Consent artifact request from Consumer
description: Consent artifact request from Consumer
operationId: registerConsent
requestBody:
description: Consent artifact request from Consumer
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentArtifact'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/RegisterResponse'
/init:
post:
tags:
- init
summary: Initialize the loan by filling out the application form
description: Initialize the loan by filling out the application form
requestBody:
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- init
required:
- action
message:
type: object
properties:
order:
$ref: '#/components/schemas/SelectResponseObject'
required:
- order
required:
- context
- message
example:
context:
domain: agriculture
action: init
version: 1.0.0
bap_id: YASH-local-PS-BAP
bap_uri: https://4de3-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
bpp_id: bpp.dsep.samagra.io
bpp_uri: https://1a0d-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
transaction_id: a9aaecca-10b7-4d19-b640-b047a7c62196
message_id: $bb579fb8-cb82-4824-be12-fcbc405b6608
timestamp: '2022-12-12T09:55:41.161Z'
ttl: PT10M
message:
order:
id: order_123546876
provider:
id: BANK 1
descriptor:
name: BANK 1
items:
- id: '1'
descriptor:
name: LOAN PRODUCT
price:
currency: INR
value: '121345'
provider:
id: BANK 1
tags:
- block: string
district: string
loan_tenure: string
interest_rate: 0
processing_charges: 0
fulfillmentes:
- id: fulfillment_id
type: fulfillment_type
provider_id: BANK 1
tracking: true
agent:
name: John Doe
customer:
person:
name: Alex Copper
dob: '1980-01-01'
gender: MALE
creds:
- type: education qualification
id: 12th marksheet number
url: http://drive.google.com/link_to_doc.pdf
- type: ror
id: ror doc identifaction numnber
url: http://drive.google.com/link_to_ror.pdf
- type: aadhar card
id: aadhar number
url: http://drive.google.com/link_to_aadhar.pdf
- type: any other ID proof (PAN Card)
id: PAN Card number
url: http://drive.google.com/link_to_PAN.pdf
tags:
- descriptor:
short_desc: Personal details of the loan applicant
list:
- father-name: Michael Jordan
marital-status: SINGLE
spouse_name: NA
social_category: OBC
religion: HINDU
billing:
address: 123/45 Some Street, Great City
payment:
id: payment_id
collected_by: farmer_name
params:
bank_code: ABCD12345
tags:
- descriptor:
short_desc: Additonal bank details
list:
- PACS: BANK PACS NAME
tags:
- descriptor:
short_desc: Additonal Order Details
list:
- crop_type: rabi
land_cultivation_area: '1234'
permanent_address: 123/45 Some Street, Great City
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
message:
$ref: '#/components/schemas/SelectResponseObject'
required:
- context
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
error:
$ref: '#/components/schemas/Error'
required:
- context
/confirm:
post:
tags:
- confirm
summary: Initialize an order by providing billing and/or shipping details
description: Initialize an order by providing billing and/or shipping details
requestBody:
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- confirm
required:
- action
message:
type: object
properties:
order:
$ref: '#/components/schemas/SelectResponseObject'
required:
- order
required:
- context
- message
example:
context:
domain: agriculture
action: confirm
version: 1.0.0
bap_id: YASH-local-PS-BAP
bap_uri: https://4de3-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
bpp_id: bpp.dsep.samagra.io
bpp_uri: https://1a0d-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
transaction_id: a9aaecca-10b7-4d19-b640-b047a7c62196
message_id: $bb579fb8-cb82-4824-be12-fcbc405b6608
timestamp: '2022-12-12T09:55:41.161Z'
ttl: PT10M
message:
order:
id: order_123546876
provider:
id: BANK 1
descriptor:
name: BANK 1
items:
- id: '1'
descriptor:
name: LOAN PRODUCT
price:
currency: INR
value: '121345'
provider:
id: BANK 1
tags:
- block: string
district: string
loan_tenure: string
interest_rate: 0
processing_charges: 0
fulfillmentes:
- id: fulfillment_id
type: fulfillment_type
provider_id: BANK 1
tracking: true
agent:
name: John Doe
customer:
person:
name: Alex Copper
dob: '1980-01-01'
gender: MALE
creds:
- type: education qualification
id: 12th marksheet number
url: http://drive.google.com/link_to_doc.pdf
- type: ror
id: ror doc identifaction numnber
url: http://drive.google.com/link_to_ror.pdf
- type: aadhar card
id: aadhar number
url: http://drive.google.com/link_to_aadhar.pdf
- type: any other ID proof (PAN Card)
id: PAN Card number
url: http://drive.google.com/link_to_PAN.pdf
tags:
- descriptor:
short_desc: Personal details of the loan applicant
list:
- father-name: Michael Jordan
marital-status: SINGLE
spouse_name: NA
social_category: OBC
religion: HINDU
billing:
address: 123/45 Some Street, Great City
payment:
id: payment_id
collected_by: farmer_name
params:
bank_code: ABCD12345
tags:
- descriptor:
short_desc: Additonal bank details
list:
- PACS: BANK PACS NAME
tags:
- descriptor:
short_desc: Additonal Order Details
list:
- crop_type: rabi
land_cultivation_area: '1234'
permanent_address: 123/45 Some Street, Great City
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
message:
$ref: '#/components/schemas/SelectResponseObject'
required:
- context
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
error:
$ref: '#/components/schemas/Error'
required:
- context
/track:
post:
tags:
- track
description: Track an active order
summary: Track an active order
requestBody:
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- track
required:
- action
message:
type: object
properties:
order_id:
type: string
callback_url:
description: An URL where the actual tracking details (in our case loan application with review status) is hosted for fetching and display
type: string
format: uri
required:
- order_id
required:
- context
- message
example:
context:
domain: agriculture
action: track
version: 1.0.0
bap_id: YASH-local-PS-BAP
bap_uri: https://4de3-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
bpp_id: bpp.dsep.samagra.io
bpp_uri: https://1a0d-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
transaction_id: a9aaecca-10b7-4d19-b640-b047a7c62196
message_id: $bb579fb8-cb82-4824-be12-fcbc405b6608
timestamp: '2022-12-12T09:55:41.161Z'
ttl: PT10M
message:
order_id: order-1681225144247
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_track
required:
- action
message:
type: object
properties:
tracking:
type: object
properties:
id:
type: string
url:
type: string
status:
type: string
enum: [ 'active', 'inactive' ]
required:
- context
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
error:
$ref: '#/components/schemas/Error'
required:
- context
/update:
post:
tags:
- update
description: Respond to any queries that the bank has raised
summary: Respond to any queries that the bank has raised
requestBody:
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- update
required:
- action
message:
type: object
properties:
update_target:
description: >-
Comma separated values of order objects being updated.
For example:
```"update_target":"item,billing,fulfillment"```
type: string
order:
description: Updated order object
allOf:
- $ref: '#/components/schemas/SelectResponseObject'
required:
- update_target
- order
required:
- context
- message
example:
context:
domain: dsep:courses
action: update
version: 1.0.0
bap_id: YASH-local-PS-BAP
bap_uri: https://4de3-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
bpp_id: bpp.dsep.samagra.io
bpp_uri: https://1a0d-2401-4900-1c6e-578a-4bca-7bf8-cfae-148a.in.ngrok.io
transaction_id: a9aaecca-10b7-4d19-b640-b047a7c62196
message_id: $bb579fb8-cb82-4824-be12-fcbc405b6608
timestamp: '2022-12-12T09:55:41.161Z'
ttl: PT10M
message:
update_target: PAN, Aadhar
order:
id: order_123546876
provider:
id: BANK 1
descriptor:
name: BANK 1
items:
- id: '1'
descriptor:
name: LOAN PRODUCT
price:
currency: INR
value: '121345'
provider:
id: BANK 1
tags:
- block: string
district: string
loan_tenure: string
interest_rate: 0
processing_charges: 0
fulfillmentes:
- id: fulfillment_id
type: fulfillment_type
provider_id: BANK 1
tracking: true
agent:
name: John Doe
customer:
person:
name: Alex Copper
dob: '1980-01-01'
gender: MALE
creds:
- type: education qualification
id: 12th marksheet number
url: http://drive.google.com/link_to_doc.pdf
- type: ror
id: ror doc identifaction numnber
url: http://drive.google.com/link_to_ror.pdf
- type: aadhar card
id: aadhar number
url: http://drive.google.com/link_to_aadhar.pdf
- type: any other ID proof (PAN Card)
id: PAN Card number
url: http://drive.google.com/link_to_PAN.pdf
tags:
- descriptor:
short_desc: Personal details of the loan applicant
list:
- father-name: Michael Jordan
marital-status: SINGLE
spouse_name: NA
social_category: OBC
religion: HINDU
billing:
address: 123/45 Some Street, Great City
payment:
id: payment_id
collected_by: farmer_name
params:
bank_code: ABCD12345
tags:
- descriptor:
short_desc: Additonal bank details
list:
- PACS: BANK PACS NAME
tags:
- descriptor:
short_desc: Additonal Order Details
list:
- crop_type: rabi
land_cultivation_area: '1234'
permanent_address: 123/45 Some Street, Great City
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
message:
type: object
properties:
catalog:
$ref: '#/components/schemas/SelectResponseObject'
required:
- catalog
error:
$ref: '#/components/schemas/Error'
required:
- context
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
context:
allOf:
- $ref: '#/components/schemas/Context'
- properties:
action:
enum:
- on_search
required:
- action
error:
$ref: '#/components/schemas/Error'
required:
- context
components:
schemas:
Catalog:
description: >-
Describes the products or services offered by a BPP. This is typically
sent as the response to a search intent from a BAP. The payment terms,
offers and terms of fulfillment supported by the BPP can also be
included here. The BPP can show hierarchical nature of products/services
in its catalog using the parent_category_id in categories. The BPP can
also send a ttl (time to live) in the context which is the duration for
which a BAP can cache the catalog and use the cached catalog.
This
has properties like
bbp/descriptor,bbp/categories,bbp/fulfillments,bbp/payments,bbp/offers,bbp/providers
and exp
This is used in the following situations.