PHP RestAPI
PHP RestAPI
Introduction
Headers
Field Description
Auth
Auth - GenerateToken
Generates the token required to access the API. The expiration date is one hour.
POST
/oauth/v2/token
Request
grant_type String
Grant type. Const: client_credentials
client_id String
Client identifier. Constant value provided by PM.
client_secret String
Client secret. Constant value provided by PM.
project String
(Optional) Specified project code name.
Response
access_token String
Required to access the API. Authorization: Bearer {{access_token}}.
expires_in String
Token life in seconds.
token_type String
Type of token.
scope String
Scope.
https://ins-rest-api.int.ccig.pl/doc/index.html 1/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Request-Example [#parameter-examples-Auth-GenerateToken-1_0_0-0]
{
"grant_type": "client_credentials",
"client_id": "4_nvcv66vcyog8ksg48kgkg4k8co8sskcsw0wgg0w8wwg0ksw0k",
"client_secret": "4iz0e44j4fc4ccc088kw0wg0gwsswoosokok0cosgk0g40gc8w",
"project": "testintranet"
}
Success-Response: [#success-examples-Auth-GenerateToken-1_0_0-0]
Error-Response: [#success-examples-Auth-GenerateToken-1_0_0-1]
HTTP/1.1 200 OK
{
"access_token": "NDJlNTk2NTBmZGFmMWU4NjU0YTFjMTdmZTExODFlMzgzOGRiMDhhZmQ4Y2M4NzExODY3ZTFkMmMyNDlhMzU4Yw
"expires_in": 3600,
"token_type": "bearer",
"scope": "scope1 scope2"
}
Campaigns
Campaigns - CustomersSales
Get all campaigns customers sales by customer unique ID.
GET
/api/out/v1/campaigns/:id/customers/:customerId/sales
Request
Page Integer
Paginator current page.
from_date String
From date. Required format: Y-m-d H:i:s
to_date String
To date. Required format: Y-m-d H:i:s
Parameter
id Number
Campaign unique ID.
customerId String
Customer unique ID.
Response
https://ins-rest-api.int.ccig.pl/doc/index.html 2/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
customer_id Number
Customer unique ID.
campaign String
Campaign name.
phone_number String
Customer phone number.
created_at DateTime
Date of sale made.
user_login String
Consultant username.
status String
Sale status.
sale_id String
Sale unique ID.
data Array
Polls data.
Response [data]
widget_id Number
Section unique ID.
answer_id Number
Answer unique ID.
answer_value String
Answer contents.
Success: [#success-examples-Campaigns-getCustomersSales-1_0_0-0]
https://ins-rest-api.int.ccig.pl/doc/index.html 3/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
HTTP/1.1 200 OK
{
"previous": "",
"current": "",
"next": "",
"data": [
{
"customer_id": 1,
"campaign": "Test campaign",
"phone_number": "123456789",
"created_at": "2018-01-01 15:30:00",
"user_login": "test.test",
"status": "Sukces",
"note": [],
"data": [
{
"widget_id": "1614470262441521",
"answer_id": "1614470262441075",
"answer_value": "Aktywacja"
},
{
"widget_id": "1614470262443404",
"answer_id": "1614470262442826",
"answer_value": "Internet Mobilny Optymalny na raty 39.99"
}
]
}
],
"errors": [],
"total": 1
}
BadRequest: [#error-examples-Campaigns-getCustomersSales-1_0_0-0]
Campaigns - CustomersStatusChanges
Get all campaigns customers status changes by customer ID.
GET
/api/out/v1/campaigns/:id/customers/:customerId/status_changes
Request
Page Integer
Paginator current page.
from_date String
From date. Required format: Y-m-d H:i:s
to_date String
To date. Required format: Y-m-d H:i:s
Parameter
https://ins-rest-api.int.ccig.pl/doc/index.html 4/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
id Number
Campaign unique ID.
customerId String
Customer unique ID.
Response
id Number
Status Change unique ID.
campaign_id Number
Campaign unique ID.
customer_id Number
Customer unique ID.
new_status_id Number
New status unique ID.
new_status String
New status name.
created_at DateTime
Date of status change.
created_by String
Consultant username.
phone_number String
Customer phone number.
Success: [#success-examples-Campaigns-CustomersStatusChanges-1_0_0-0]
HTTP/1.1 200 OK
{
"previous": "",
"current": "",
"next": "",
"data": [
{
"id": 320,
"campaign_id": 10,
"customer_id": 1087,
"new_status_id": 1,
"new_status": "Sukces",
"old_status_id": 6,
"old_status": "Błąd sieci - BUSY",
"created_at": "2018-10-16 14:32:05",
"created_by": "jurek.jurecki",
"phone_number": "234567890"
}
],
"errors": [],
"total": 1
}
BadRequest: [#error-examples-Campaigns-CustomersStatusChanges-1_0_0-0]
https://ins-rest-api.int.ccig.pl/doc/index.html 5/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Campaigns - CustomersTagSales
Get all campaign customers sales by manage TAG.
GET
/api/out/v1/campaigns/:id/customers/:tagName/:tagValue/sales
Request
Page Integer
Paginator current page.
from_date String
From date. Required format: Y-m-d H:i:s
to_date String
To date. Required format: Y-m-d H:i:s
Parameter
id Number
Campaign unique ID.
tagName String
Tag name.
tagValue String
Tag value.
Response
customer_id Number
Customer unique ID.
campaign String
Campaign name.
phone_number String
Customer phone number.
created_at DateTime
Date of sale made.
user_login String
Consultant username.
https://ins-rest-api.int.ccig.pl/doc/index.html 6/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
status String
Sale status.
sale_id String
Sale unique ID.
note Array
Additional sale note.
Success: [#success-examples-Campaigns-CustomersTagSales-1_0_0-0]
HTTP/1.1 200 OK
{
"previous": "",
"current": "",
"next": "",
"data": [
{
"customer_id": 1,
"campaign": "Test campaign",
"phone_number": "123456789",
"created_at": "2018-01-01 15:30:00",
"user_login": "test.test",
"status": "Sukces",
"note": []
}
],
"errors": [],
"total": 1
}
Error 4xx
Name Description
BadRequest
Id is not valid.
InvalidTag
tagName is not valid.
TagIsNotManage
tagName is not manage.
BadRequest: [#error-examples-Campaigns-CustomersTagSales-1_0_0-0]
InvalidTag: [#error-examples-Campaigns-CustomersTagSales-1_0_0-1]
TagIsNotManage: [#error-examples-Campaigns-CustomersTagSales-1_0_0-2]
https://ins-rest-api.int.ccig.pl/doc/index.html 7/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Campaigns - CustomersTagStatusChanges
Get all campaigns customers status changes by manage TAG.
GET
/api/out/v1/campaigns/:id/customers/:tagName/:tagValue/status_changes
Request
Page Integer
Paginator current page.
from_date String
From date. Required format: Y-m-d H:i:s
to_date String
To date. Required format: Y-m-d H:i:s
Parameter
id Number
Campaign unique ID.
tagName String
Tag name.
tagValue String
Tag value.
Response
id Number
Status Change unique ID.
https://ins-rest-api.int.ccig.pl/doc/index.html 8/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
campaign_id Number
Campaign unique ID.
customer_id Number
Customer unique ID.
new_status_id Number
New status unique ID.
new_status String
New status name.
created_at DateTime
Date of status change.
created_by String
Consultant username.
phone_number String
Customer phone number.
Success: [#success-examples-Campaigns-CustomersTagStatusChanges-1_0_0-0]
HTTP/1.1 200 OK
{
"previous": "",
"current": "",
"next": "",
"data": [
{
"id": 320,
"campaign_id": 10,
"customer_id": 1087,
"new_status_id": 1,
"new_status": "Sukces",
"created_at": "2018-10-16 14:32:05",
"created_by": "jurek.jurecki",
"phone_number": "123456789"
}
],
"errors": [],
"total": 1
}
Error 4xx
Name Description
BadRequest
Id is not valid.
InvalidTag
tagName is not valid.
TagIsNotManage
tagName is not manage.
BadRequest: [#error-examples-Campaigns-CustomersTagStatusChanges-1_0_0-0]
InvalidTag: [#error-examples-Campaigns-CustomersTagStatusChanges-1_0_0-1]
TagIsNotManage: [#error-examples-Campaigns-CustomersTagStatusChanges-1_0_0-2]
https://ins-rest-api.int.ccig.pl/doc/index.html 9/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Campaigns - Sales
Get all campaigns sales.
GET
/api/out/v1/campaigns/:id/sales
Request
Page Integer
Paginator current page.
from_date String
From date. Required format: Y-m-d H:i:s
to_date String
To date. Required format: Y-m-d H:i:s
Parameter
id Number
Campaign unique ID.
https://ins-rest-api.int.ccig.pl/doc/index.html 10/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Response
customer_id Number
Customer unique ID.
talk_name String
Talk unique name.
campaign String
Campaign name.
phone_number String
Customer phone number.
created_at DateTime
Date of sale made.
user_login String
Consultant username.
status String
Sale status.
note Array
Note data.
data Array
Polls data.
Response [note]
sale_id String
Sale unique ID.
note String
Additional sale note.
username String
Username of Consultant which created note.
created_at String
Date of note creation.
Response [data]
widget_id Number
Section unique ID.
answer_id Number
Answer unique ID.
answer_value String
Answer contents.
Success: [#success-examples-Campaigns-Sales-1_0_0-0]
https://ins-rest-api.int.ccig.pl/doc/index.html 11/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
HTTP/1.1 200 OK
{
"previous": "",
"current": "",
"next": "",
"data": [
{
"customer_id": 1,
"talk_name": "MjAxOC4xMC4xMC0wOTo0Mjo1My0wOS0wMDc4LTE2LTAxLTAwLTA2MTYwOS01MTA0Mjk5OTktMDkwMDc4MTYw
"campaign": "Test campaign",
"phone_number": "123456789",
"created_at": "2018-01-01 15:30:00",
"user_login": "test.test",
"status": "Sukces",
"note": [
0: {
"sale_id": 10,
"note": "Test note",
"username": "test.test",
"created_at": "2018-01-01 15:30:00"
}
],
"data": [
{
"widget_id": "1614470262441521",
"answer_id": "1614470262441075",
"answer_value": "Aktywacja"
},
{
"widget_id": "1614470262443404",
"answer_id": "1614470262442826",
"answer_value": "Internet Mobilny Optymalny na raty 39.99"
}
]
},
{
"customer_id": 2,
"campaign": "Test campaign",
"phone_number": "23456789",
"created_at": "2018-01-01 15:30:00",
"user_login": "test2.test2",
"status": "Sukces",
"note": [],
"data": []
}
],
"errors": [],
"total": 2
}
Error 4xx
Name Description
BadRequest
Id is not valid.
BadRequest: [#error-examples-Campaigns-Sales-1_0_0-0]
https://ins-rest-api.int.ccig.pl/doc/index.html 12/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Campaigns - StatusChanges
Get all campaigns status changes.
GET
/api/out/v1/campaigns/:id/status_changes
Request
Page Integer
Paginator current page.
from_date String
From date. Required format: Y-m-d H:i:s
to_date String
To date. Required format: Y-m-d H:i:s
Parameter
id Number
Campaign unique ID.
Response
id Number
Status Change unique ID.
campaign_id Number
Campaign unique ID.
customer_id Number
Customer unique ID.
new_status_id Number
New status unique ID.
new_status String
New status name.
created_at DateTime
Date of status change.
created_by String
Consultant username.
phone_number String
Customer phone number.
Success: [#success-examples-Campaigns-StatusChanges-1_0_0-0]
https://ins-rest-api.int.ccig.pl/doc/index.html 13/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
HTTP/1.1 200 OK
{
"previous": "",
"current": "",
"next": "",
"data": [
{
"id": 320,
"campaign_id": 10,
"customer_id": 1087,
"new_status_id": 1,
"new_status": "Sukces",
"old_status_id": 6,
"old_status": "Błąd sieci - BUSY",
"created_at": "2018-10-16 14:32:05",
"created_by": "jurek.jurecki",
"phone_number": "234567890"
},
{
"id": 321,
"campaign_id": 10,
"customer_id": 1090,
"new_status_id": 1,
"new_status": "Sukces",
"created_at": "2018-10-17 15:50:00",
"created_by": "jurek.jurecki",
"phone_number": "123456789"
},
],
"errors": [],
"total": 2
}
Error 4xx
Name Description
BadRequest
Id is not valid.
BadRequest: [#error-examples-Campaigns-StatusChanges-1_0_0-0]
Customers
PUT
/api/out/v1/customers/{campaignId}/close
https://ins-rest-api.int.ccig.pl/doc/index.html 14/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Request
customers Array
Array of clients
{
"customers": [
{
"tag_id": "5",
"value": "190123456"
}
]
}
Success: [#success-examples-Customers-PutCloseWithCampaign-1_0_0-0]
HTTP/1.1 200 OK
{
"data": [
"id": 234566,
"details": [
{
"value": "123456789",
"original_label": "Numer telefonu"
}
]
],
"errors": [],
"total": 1
}
Error 4xx
Name Description
BadRequest
Id is not valid.
BadRequest: [#error-examples-Customers-PutCloseWithCampaign-1_0_0-0]
Customers - Close
Put all specified customers to close.
PUT
/api/out/v1/customers/close
Request
https://ins-rest-api.int.ccig.pl/doc/index.html 15/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
customers Array
Array of clients
customer_id integer
Customer ID.
tag_id integer
Tag ID.
value String
Tag VALUE.
campaign_id integer
(Optional) Campaign ID.
{
"customers": [
{
"customer_id": "1087"
}
]
}
{
"customers": [
{
"tag_id": "5",
"value": "190123456"
}
]
}
{
"customers": [
{
"tag_id": "5",
"value": "190123456",
"campaign_id": 12
}
]
}
Success: [#success-examples-Customers-PutClose-1_0_0-0]
HTTP/1.1 200 OK
{
"data": [
"id": 234566,
"details": [
{
"value": "123456789",
"original_label": "Numer telefonu"
}
]
],
"errors": [],
"total": 1
}
Error 4xx
https://ins-rest-api.int.ccig.pl/doc/index.html 16/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Name Description
BadRequest
Id is not valid.
BadRequest: [#error-examples-Customers-PutClose-1_0_0-0]
Import
Import - Config
It builds an example configuration with the required "tags" for the client and campaign
GET
/api/out/v1/import/config/{id}
Request
id Integer
Campaign identifier
Success-Response: [#success-examples-Import-GetConfig-1_0_0-0]
Error-Response: [#success-examples-Import-GetConfig-1_0_0-1]
HTTP/1.1 200 OK
{
"data": {
"campaign_id": "54",
"customers": [
{
"details": {
"Data": "***",
"Numer telefonu": "***",
"Pesel": "***",
"Tekst": "***"
}
},
{
"details": {
"Data": "***",
"Numer telefonu": "***",
"Pesel": "***",
"Tekst": "***"
}
}
]
}
}
https://ins-rest-api.int.ccig.pl/doc/index.html 17/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
Import - Customers
Imports the customers base to previously configured
POST
/api/out/v1/import
Request
campaign_id Integer
Campaign identifier
customers Array
Array of clients with pre-defined tags
Request-Example [#parameter-examples-Import-PostCustomers-1_0_0-0]
{
"campaign_id": 22,
"customers": [
{
"details": {
"Numer telefonu": "502618874",
"Tekst": "Customer 1",
"Data": "2019-01-01",
"Pesel": "7912345345"
}
},
{
"details": {
"Numer telefonu": "502618876",
"Tekst": "DCustomer 2",
"Data": "2019-01-01",
"Pesel": "7912345345"
}
}
]
}
Success-Response: [#success-examples-Import-PostCustomers-1_0_0-0]
Error-Response: [#success-examples-Import-PostCustomers-1_0_0-1]
https://ins-rest-api.int.ccig.pl/doc/index.html 18/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
HTTP/1.1 200 OK
"data": [
{
"id": "200093",
"details": [
{
"value": "2019-01-01",
"original_label": "Data"
},
{
"value": "502618874",
"original_label": "Numer telefonu"
}
]
}
],
"errors": []
}
Error statuses
Name Description
BAD_REQUEST
Unknown input data or no required data
Sale
Sale - Change state by sale field.
Change sales state by sale field type and value.
POST
/api/out/v1/sales/state_change
Request
field_type String
Field name("externalId", "saleId", "transNumber").
field_value String/Integer
Field value. If field_type is saleId field_value must be integer.
https://ins-rest-api.int.ccig.pl/doc/index.html 19/20
25.05.2023, 11:32 apiDoc: PHP Rest Api - 1.0.0
status_codename String
Status codename.
Request-Example [#parameter-examples-Sale-PostChangeSaleState-1_0_0-0]
{
"sales": [
{
"field_type": "externalId",
"field_value": "B2C",
"status_codename": "cancelled"
},
{
"field_type": "saleId",
"field_value": "12345",
"status_codename": "registered"
},
{
"field_type": "transNumber",
"field_value": "dsa",
"status_codename": "partial_sale"
}
]
}
Success: [#success-examples-Sale-PostChangeSaleState-1_0_0-0]
HTTP/1.1 200 OK
[
{
"field_type": "externalId"
"field_value": "12345",
"status_codename": "registered",
"message": "Success."
}
]
BadRequest: [#error-examples-Sale-PostChangeSaleState-1_0_0-0]
https://ins-rest-api.int.ccig.pl/doc/index.html 20/20