### GET /ProfitRestServices/connectors/ProfitCountries Source: https://docs.afas.help/profit/nl/howto-quickstart Retrieves a list of countries from the AFAS Profit system. Supports pagination with 'skip' and 'take' query parameters. ```APIDOC ## GET /ProfitRestServices/connectors/ProfitCountries ### Description Retrieves a list of countries from the AFAS Profit system. Supports pagination with 'skip' and 'take' query parameters. ### Method GET ### Endpoint `https://{your_afas_domain}/ProfitRestServices/connectors/ProfitCountries?skip={skip_value}&take={take_value}` ### Query Parameters - **skip** (integer) - Optional - The number of records to skip from the beginning. - **take** (integer) - Optional - The maximum number of records to return. ### Request Headers - **Accept**: `application/json` - **Accept-Language**: `nl-nl` (or other desired language code) - **Authorization**: `AfasToken YOUR_TOKEN_HERE` ### Request Example (Visual Basic) ```vb Imports System.Net Imports System.IO Imports System.Text Module Module1 Sub Main() Dim apiUrl As String = "https://12345.rest.afas.online/ProfitRestServices/connectors/ProfitCountries?skip=0&take=100" Dim request As WebRequest = WebRequest.Create(apiUrl) request.Method = "GET" request.Headers.Add("Accept", "application/json") request.Headers.Add("Accept-Language", "nl-nl") request.Headers.Add("Authorization", "AfasToken PHRva2VuPjx2ZXJzaW9uPjE8L3ZlcnNpb24+PGRhdGE+QURFMzcwQkU4REFGNDBEMEExN0ZGQjkxNEU0MjY3NUU5OTk4QzJENTQ2QTJGNEZBM0U0RjNBQkZBODY3Qjk2RjwvZGF0YT48L3Rva2VuPg==") Dim response As WebResponse = request.GetResponse() Dim responseStream As Stream = response.GetResponseStream() Dim reader As New StreamReader(responseStream, Encoding.UTF8) Dim responseContent As String = reader.ReadToEnd() Console.WriteLine(responseContent) response.Close() reader.Close() End Sub End Module ``` ### Request Example (PHP) ```php "https://12345.rest.afas.online/ProfitRestServices/connectors/ProfitCountries?skip=0&take=100", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Accept: application/json", "Accept-Language: nl-nl", "Authorization: AfasToken PHRva2VuPjx2ZXJzaW9uPjE8L3ZlcnNpb24+PGRhdGE+QURFMzcwQkU4REFGNDBEMEExN0ZGQjkxNEU0MjY3NUU5OTk4QzJENTQ2QTJGNEZBM0U0RjNBQkZBODY3Qjk2RjwvZGF0YT48L3Rva2VuPg==" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` ### Request Example (Go) ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { url := "https://12345.rest.afas.online/ProfitRestServices/connectors/ProfitCountries?skip=0&take=100" client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Accept-Language", "nl-nl") req.Header.Add("Authorization", "AfasToken PHRva2VuPjx2ZXJzaW9uPjE8L3ZlcnNpb24+PGRhdGE+QURFMzcwQkU4REFGNDBEMEExN0ZGQjkxNEU0MjY3NUU5OTk4QzJENTQ2QTJGNEZBM0U0RjNBQkZBODY3Qjk2RjwvZGF0YT48L3Rva2VuPg==") resp, err := client.Do(req) if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } var data interface{} err = json.Unmarshal(body, &data) if err != nil { fmt.Println("Error parsing JSON:", err) return } fmt.Println("Response:", data) } ``` ### Success Response (200) Returns a JSON array of country objects. - **code** (string) - The country code. - **description** (string) - The description of the country. ### Response Example ```json [ { "code": "NL", "description": "Netherlands" }, { "code": "BE", "description": "Belgium" } ] ``` ``` -------------------------------- ### Financial Setup and Tax Endpoints Source: https://docs.afas.help/profit/spec/nl/allendpoints Endpoints for financial setup, general ledger accounts, bank transactions, and tax calculations. ```APIDOC ## POST/PUT/DELETE FiIVY ### Description Manages financial setup per year. ### Method POST, PUT, DELETE ### Endpoint /websites/afas_help/api/FiIVY ## POST/PUT/DELETE KnAccount ### Description Manages general ledger accounts. ### Method POST, PUT, DELETE ### Endpoint /websites/afas_help/api/KnAccount ## POST/PUT/DELETE KnBankTransaction ### Description Manages bank transaction settings. ### Method POST, PUT, DELETE ### Endpoint /websites/afas_help/api/KnBankTransaction ## POST/PUT/DELETE KnDimCode ### Description Manages specification codes. ### Method POST, PUT, DELETE ### Endpoint /websites/afas_help/api/KnDimCode ## POST TxCFVpb2022 ### Description Prepares corporate tax (Vpb) 2022. ### Method POST ### Endpoint /websites/afas_help/api/TxCFVpb2022 ## POST TxCFVpb2023 ### Description Prepares corporate tax (Vpb) 2023. ### Method POST ### Endpoint /websites/afas_help/api/TxCFVpb2023 ## POST TxClientIB2022 ### Description Prepares client income tax (IB) 2022. ### Method POST ### Endpoint /websites/afas_help/api/TxClientIB2022 ## POST TxClientIB2023 ### Description Prepares client income tax (IB) 2023. ### Method POST ### Endpoint /websites/afas_help/api/TxClientIB2023 ## POST TxClientVpb2022 ### Description Prepares client corporate tax (Vpb) 2022. ### Method POST ### Endpoint /websites/afas_help/api/TxClientVpb2022 ## POST TxClientVpb2023 ### Description Prepares client corporate tax (Vpb) 2023. ### Method POST ### Endpoint /websites/afas_help/api/TxClientVpb2023 ## POST TxKlaarzettenAangifte ### Description Prepares tax return filing. ### Method POST ### Endpoint /websites/afas_help/api/TxKlaarzettenAangifte ## POST TxMachtiging ### Description Manages tax authorizations. ### Method POST ### Endpoint /websites/afas_help/api/TxMachtiging ``` -------------------------------- ### Retrieve AFAS Country Data with Go Source: https://docs.afas.help/profit/nl/howto-quickstart This Go program demonstrates how to fetch data from the AFAS ProfitCountries API using the net/http package. It constructs an HTTP GET request, sets the required headers for authentication and content type, sends the request, and processes the JSON response. Error handling is included for request creation, execution, and response body reading/parsing. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { url := "https://12345.rest.afas.online/ProfitRestServices/connectors/ProfitCountries?skip=0&take=100" client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Accept-Language", "nl-nl") req.Header.Add("Authorization", "AfasToken PHRva2VuPjx2ZXJzaW9uPjE8L3ZlcnNpb24+PGRhdGE+QURFMzcwQkU4REFGNDBEMEExN0ZGQjkxNEU0MjY3NUU5OTk4QzJENTQ2QTJGNEZBM0U0RjNBQkZBODY3Qjk2RjwvZGF0YT48L3Rva2VuPg==") resp, err := client.Do(req) if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } var data interface{} err = json.Unmarshal(body, &data) if err != nil { fmt.Println("Error parsing JSON:", err) return } fmt.Println("Response:", data) } ``` -------------------------------- ### Retrieve AFAS Country Data with Visual Basic Source: https://docs.afas.help/profit/nl/howto-quickstart This Visual Basic code snippet demonstrates how to make an authenticated GET request to the AFAS ProfitCountries API endpoint. It sets up the WebRequest, adds necessary headers including authentication token, and reads the JSON response. Ensure the System.Net, System.IO, and System.Text namespaces are imported. ```vb Imports System.Net Imports System.IO Imports System.Text Module Module1 Sub Main() ' Set the API endpoint URL Dim apiUrl As String = "https://12345.rest.afas.online/ProfitRestServices/connectors/ProfitCountries?skip=0&take=100" ' Create a new WebRequest Dim request As WebRequest = WebRequest.Create(apiUrl) ' Set the request method to GET request.Method = "GET" ' Set the request headers request.Headers.Add("Accept", "application/json") request.Headers.Add("Accept-Language", "nl-nl") request.Headers.Add("Authorization", "AfasToken PHRva2VuPjx2ZXJzaW9uPjE8L3ZlcnNpb24+PGRhdGE+QURFMzcwQkU4REFGNDBEMEExN0ZGQjkxNEU0MjY3NUU5OTk4QzJENTQ2QTJGNEZBM0U0RjNBQkZBODY3Qjk2RjwvZGF0YT48L3Rva2VuPg==") ' Send the request and get the response Dim response As WebResponse = request.GetResponse() ' Get the response stream Dim responseStream As Stream = response.GetResponseStream() ' Create a StreamReader to read the response Dim reader As New StreamReader(responseStream, Encoding.UTF8) ' Read the response content Dim responseContent As String = reader.ReadToEnd() ' Print the response content Console.WriteLine(responseContent) ' Close the response and reader response.Close() reader.Close() End Sub End Module ``` -------------------------------- ### C# HttpClient Pagination Example Source: https://docs.afas.help/sb/nl/pagination Provides an example using C#'s HttpClient to interact with the AFAS API for paginated and sorted data retrieval. It sets up the HttpClient with necessary headers, constructs the request URL with query parameters, sends a GET request, and processes the successful response. Error handling for non-successful status codes is included. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; namespace ApiExample { class Program { static async Task Main(string[] args) { using HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "{your_api_key}"); client.DefaultRequestHeaders.Add("Content-Type", "application/json"); var queryParams = "?skip=10&take=10&sort=VeldNaam+descending"; var response = await client.GetAsync("https://demo.afasfocus.nl/Omgeving/api/endpoint" + queryParams); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); Console.WriteLine(content); } } } } ``` -------------------------------- ### POST Create Sales Relation Source: https://docs.afas.help/profit/nl/howto-plaatsing Creates a new sales relation. It's recommended to start with creating a sales relation before proceeding with other related entities. ```APIDOC ## POST Create Sales Relation ### Description Endpoint for creating a sales relation. The example provided demonstrates how to ensure a new organization is always created by setting `"MatchOga": "6"`. ### Method POST ### Endpoint /api/sales-relations ### Parameters #### Request Body - **KnSalesRelationOrg** (object) - Required - The data for the sales relation. - **Element** (object) - Required - Contains the details of the sales relation. - **@DbId** (string) - Required - The database ID. - **Fields** (object) - Required - Fields for the sales relation. - **VaId** (string) - Required - Some value identifier. - **CuId** (string) - Required - Currency identifier. - **InPv** (string) - Required - Invoice parameter. - **Objects** (array) - Optional - Associated objects. - **KnOrganisation** (object) - Represents the organization. - **Element** (object) - Organization details. - **Fields** (object) - Organization fields. - **PadAdr** (boolean) - Optional - Indicates if it's a postal address. - **AutoNum** (boolean) - Optional - Indicates if the number is auto-generated. - **MatchOga** (string) - Required - Controls organization matching (e.g., '6' for new organization). - **SeNm** (string) - Required - Search name. - **Nm** (string) - Required - Organization name. - **CcNr** (string) - Optional - Company number. - **CcDa** (string) - Optional - Company date. - **NmRg** (string) - Optional - Registered name. - **HoPa** (string) - Optional - Website URL. - **Objects** (array) - Optional - Associated address objects. - **KnBasicAddressAdr** (object) - Represents the basic address. - **Element** (object) - Address details. - **Fields** (object) - Address fields. - **CoId** (string) - Required - Country ID. - **PbAd** (boolean) - Optional - Indicates if it's a primary address. - **Ad** (string) - Required - Street name. - **HmNr** (string) - Required - House number. - **ZpCd** (string) - Required - Postal code. - **Rs** (string) - Required - City/Region. - **ResZip** (boolean) - Optional - Indicates if the postal code is restricted. ### Request Example ```json { "KnSalesRelationOrg": { "Element": { "@DbId": "49339", "Fields": { "VaId": "111234567B01", "CuId": "EUR", "InPv": "E" }, "Objects": [ { "KnOrganisation": { "Element": { "Fields": { "PadAdr": true, "AutoNum": true, "MatchOga": "6", "SeNm": "ZOEKNAAM", "Nm": "Jansen", "CcNr": "93056589", "CcDa": "2024-03-01", "NmRg": "Jansen Personeel B.V.", "HoPa": "www.jansen.test" }, "Objects": [ { "KnBasicAddressAdr": { "Element": { "Fields": { "CoId": "NL", "PbAd": false, "Ad": "Haarlemseweg", "HmNr": "105", "ZpCd": "3833LC", "Rs": "Leusden", "ResZip": false } } } } ] } } } ] } } } ``` ### Response #### Success Response (200) - **KnSalesRelationOrg** (object) - Contains identifiers for the created sales relation. - **DbId** (string) - The database ID of the created sales relation. - **BcCo** (string) - Some company code. - **BcId** (string) - Some business identifier. #### Response Example ```json { "KnSalesRelationOrg": { "DbId": "49339", "BcCo": "100172", "BcId": "2604" } } ``` **Note**: The `DbId` value from this response is required for subsequent requests. ``` -------------------------------- ### Example Response for Client Credentials Flow Access Token Source: https://docs.afas.help/profit/nl/authentication Provides an example of the JSON response received after successfully requesting an access token using the Client Credentials Flow. It includes the 'access_token', 'token_type', and 'expires_in' fields necessary for API authorization. ```json { "access_token": "", "refresh_token": null, "token_type": "Bearer", "expires_in": 3600 } ``` -------------------------------- ### Get All Records (Not Recommended) Source: https://docs.afas.help/profit/nl/get-connector Demonstrates how to retrieve all records from a GetConnector by setting `skip` and `take` to -1. This method is strongly discouraged due to potential server overload and performance issues. ```APIDOC ## Get All Records (Not Recommended) ### Description This method retrieves all records from a GetConnector by setting `skip` and `take` to -1. This approach is highly discouraged due to potential performance degradation and server strain. ### Method GET ### Endpoint `/{connector}?skip=-1&take=-1` ### Parameters #### Query Parameters - **skip** (integer) - Set to -1 to indicate no records should be skipped. - **take** (integer) - Set to -1 to indicate all available records should be returned. ### Warning Using `skip=-1` and `take=-1` can lead to server overload, long waiting times, and system instability. It is recommended to specify a reasonable `take` value if the expected number of records is known, or implement pagination for unknown record counts. ``` -------------------------------- ### Create Customer Agreement Response (JSON) Source: https://docs.afas.help/profit/nl/howto-plaatsing This JSON response indicates the successful creation of a customer agreement via the Project endpoint. It contains the project ID (PrId) assigned to the newly created agreement, which can be used for further reference or operations. ```json { "results": { "PtProject": { "PrId": "97345" } } } ``` -------------------------------- ### Create Confrontation - Method 1 (JSON) Source: https://docs.afas.help/profit/nl/howto-finance-mutation-purch This is the first method for creating a confrontation using the POST FbConfrontation endpoint. It requires the InId of the financial mutation and OrNu of the receipt. This example includes nested objects for goods received and their lines. ```json { "FbConfrontation": { "Element": { "Fields": { "UnId": 1, "InId": "IH001057X" }, "Objects": [ { "FbGoodsReceived": { "Element": { "Fields": { "OrNu": "01893" }, "Objects": [ { "FbGoodsReceivedLines": { "Element": { "Fields": { "GuLi": "{8FDB1897-0620-4EC9-8355-1BD5199884E7}", "QuCf": "400" } } } } ] } } } ] } } } ``` -------------------------------- ### POST /websites/afas_help/PtProject Source: https://docs.afas.help/profit/nl/howto-plaatsing Creates a customer agreement by utilizing the projects function in AFAS Profit. A specific profile (-147) is designated for customer agreements. Additional details such as project groups, sales relations, and specific IDs are required. ```APIDOC ## POST /websites/afas_help/PtProject ### Description Creates a customer agreement by utilizing the projects function in AFAS Profit. A specific profile (-147) is designated for customer agreements. Additional details such as project groups, sales relations, and specific IDs are required. ### Method POST ### Endpoint /websites/afas_help/PtProject ### Parameters #### Request Body - **PtProject** (object) - Required - Contains the project element details. - **Element** (object) - Required - Represents the project element. - **Fields** (object) - Required - Contains the fields for the project. - **PrGp** (string) - Required - Project Group (e.g., "ALG"). - **Prof** (integer) - Required - Profile ID for customer agreements (e.g., -147). - **Ds** (string) - Required - Description of the agreement (e.g., "Klantovereenkomst via UpdateConnector"). - **DbId** (string) - Required - Database ID (e.g., "80418"). - **VbCo** (string) - Required - Sales relation code (e.g., "ALG"). - **PrTy** (string) - Required - Project type (e.g., "1"). - **CmId** (string) - Required - Company ID (e.g., "01"). - **VaCc** (string) - Required - Value component (e.g., "0"). - **RpDe** (string) - Required - Report definition ID (e.g., "CB285CD24020D26A3077FBAC1A0F86B2"). - **PsId** (integer) - Required - Permission schema ID (e.g., 2). - **HrWe** (integer) - Required - CAO ID of the employer (e.g., 36). - **ViTo** (string) - Required - Validity term (e.g., "1M"). - **ToTe** (integer) - Required - Term (e.g., 1). - **ToTp** (string) - Required - Term type (e.g., "W"). - **ExTe** (integer) - Required - Expiry term (e.g., 1). - **ExTp** (string) - Required - Expiry term type (e.g., "W"). - **ClId** (string) - Required - Client ID (e.g., "Basis"). - **NPDe** (string) - Required - Non-project description (e.g., "0"). - **CrMe** (string) - Required - Creation method (e.g., "2"). - **IsId** (integer) - Required - Item ID (e.g., 2). - **MeOw** (string) - Required - Member owner (e.g., "0"). ### Request Example ```json { "PtProject": { "Element": { "Fields": { "PrGp": "ALG", "Prof": -147, "Ds": "Klantovereenkomst via UpdateConnector", "DbId": "80418", "VbCo": "ALG", "PrTy": "1", "CmId": "01", "VaCc": "0", "RpDe": "CB285CD24020D26A3077FBAC1A0F86B2", "PsId": 2, "HrWe": 36, "ViTo": "1M", "ToTe": 1, "ToTp": "W", "ExTe": 1, "ExTp": "W", "ClId": "Basis", "NPDe": "0", "CrMe": "2", "IsId": 2, "MeOw": "0" } } } } ``` ### Response #### Success Response (200) - **results** (object) - Contains the results of the operation. - **PtProject** (object) - Contains the created project details. - **PrId** (string) - The ID of the created project (e.g., "97345"). #### Response Example ```json { "results": { "PtProject": { "PrId": "97345" } } } ``` ``` -------------------------------- ### Call SubjectConnector API Endpoint to Get Attachment Source: https://docs.afas.help/profit/nl/howto-bijlage-dossier This is an example of an HTTP GET request to the SubjectConnector endpoint to retrieve a specific attachment. It uses SubjectId and FileId to identify the attachment. The response includes the file data, filename, and mimetype. ```http GET https://12345.rest.afas.online/ProfitRestServices/SubjectConnector/49946/5C055C034516ED67972E0A852E03C5B9 ``` -------------------------------- ### Partner Koppeling - Publiceren op het App Center Source: https://docs.afas.help/sb/nl/start Steps for publishing your completed integration to the AFAS App Center. This involves a review process and providing necessary app details for listing. ```APIDOC ## Publiceren op het App Center Once your integration is developed, you can publish it to the AFAS App Center. ### Review Process: AFAS will review your integration for: * Working integration * Working onboarding * Working error handling ### Required App Information: * App Logo for the App Center * Support URL * App Summary * Detailed App Description * Onboarding URL ### Onboarding URL Example: Provide a URL for SB users to activate the integration. For prospects, direct them to an application onboarding page. `https://app.applicatie.nl/Appcenter/AFASSB/?afasBaseUrl=https://app-center-demo.afasfocus.nl/enyoi` ``` -------------------------------- ### GET Existing Organization / Sales Relation Source: https://docs.afas.help/profit/nl/howto-plaatsing Validates if an organization and/or person already exists. If it exists, it can be used to create the customer agreement, preventing duplicate data in AFAS. ```APIDOC ## GET Existing Organization / Sales Relation ### Description Validates if an organization and/or person already exists. If it exists, it can be used to create the customer agreement, preventing duplicate data in AFAS. ### Method GET ### Endpoint /api/organizations or /api/sales-relations ### Parameters #### Query Parameters - **search_term** (string) - Required - The name or identifier to search for. - **type** (string) - Optional - Specifies whether to search for 'organization' or 'person'. ### Request Example GET /api/organizations?search_term=Jansen Personeel B.V. ### Response #### Success Response (200) - **organizations** (array) - A list of matching organizations. - **id** (string) - The unique identifier of the organization. - **name** (string) - The name of the organization. - **persons** (array) - A list of matching persons. - **id** (string) - The unique identifier of the person. - **name** (string) - The name of the person. #### Response Example { "organizations": [ { "id": "12345", "name": "Jansen Personeel B.V." } ], "persons": [] } ``` -------------------------------- ### Retrieve AFAS Country Data with PHP Source: https://docs.afas.help/profit/nl/howto-quickstart This PHP script uses cURL to perform an authenticated GET request to the AFAS ProfitCountries API. It configures the URL, request method, and essential headers, including the authorization token. The script handles potential cURL errors and outputs the JSON response. ```php "https://12345.rest.afas.online/ProfitRestServices/connectors/ProfitCountries?skip=0&take=100", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Accept: application/json", "Accept-Language: nl-nl", "Authorization: AfasToken PHRva2VuPjx2ZXJzaW9uPjE8L3ZlcnNpb24+PGRhdGE+QURFMzcwQkU4REFGNDBEMEExN0ZGQjkxNEU0MjY3NUU5OTk4QzJENTQ2QTJGNEZBM0U0RjNBQkZBODY3Qjk2RjwvZGF0YT48L3Rva2VuPg==" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:". $err; } else { echo $response; } ?> ``` -------------------------------- ### Partner Koppeling - Aanvragen Source: https://docs.afas.help/sb/nl/start This section outlines the steps to request a partner integration with AFAS SB. It includes signing up as a partner, setting up authentication, and submitting the integration request. ```APIDOC ## Aanvragen 1. **Meld je aan als partner**: Register on the partner page to gain access to the partner network. 2. **Installeer AFAS Pocket**: Install AFAS Pocket for 2-factor authentication. 3. **Log in op partnernetwerk**: Use the provided credentials to log in. 4. **Doorloop aanmeldprocedure AFAS Online**: Complete the AFAS Online signup process (first-time users). 5. **Bevestig 2-factor authenticatie**: Confirm using AFAS Pocket. 6. **Selecteer organisatie**: Choose your organization. 7. **Klik op Aanmelden koppeling**: Submit your integration request. 8. **Selecteer SB**: Specify SB as the integration type. 9. **Vul overige velden in**: Provide complete details. 10. **Selecteer eventueel een Bijlage**: Attach necessary files. 11. **Klik op Aanmaken**: Finalize and submit the request. After submission, an AFAS System Integrator will contact you. ``` -------------------------------- ### DELETE /connectors/KnEmployeeGUID/KnEmployeeGUID/@GUID,@EmId/{GUID},{EmId} Source: https://docs.afas.help/profit/nl/news-profit3 This endpoint is used to delete employee records based on their GUID and EmId. ```APIDOC ## DELETE /connectors/KnEmployeeGUID/KnEmployeeGUID/@GUID,@EmId/{GUID},{EmId} ### Description This endpoint deletes an employee record using the provided GUID and EmId. ### Method DELETE ### Endpoint /connectors/KnEmployeeGUID/KnEmployeeGUID/@GUID,@EmId/{GUID},{EmId} ### Parameters #### Path Parameters - **GUID** (string) - Required - The unique identifier for the employee. - **EmId** (string) - Required - The employee ID. ### Response #### Success Response (200) * **message** (string) - A confirmation message indicating the employee was deleted. #### Response Example ```json { "message": "Employee deleted successfully." } ``` ``` -------------------------------- ### Ophalen salarisverwerkingsplannen met SH_AUDIT_Plannen (JSON) Source: https://docs.afas.help/profit/nl/howto-la-sa Dit codefragment demonstreert hoe je salarisverwerkingsplannen ophaalt die gerelateerd zijn aan een hoofdplan. Het gebruikt de SH_AUDIT_Plannen connector en filtert op 'Afwijkend_betaalplan' om de bijbehorende plannen te vinden. ```json { "skip": 0, "take": 20, "rows": [ { "Werkgever": "01", "Jaar": 2024, "Periode": 8, "PlanId": 935, "Afwijkend_betaalplan": 839, "Aantal": 0 }, { "Werkgever": "01", "Jaar": 2024, "Periode": 9, "PlanId": 936, "Afwijkend_betaalplan": 839, "Aantal": 1 } ] } ``` -------------------------------- ### Data Retrieval with Skip and Take Source: https://docs.afas.help/profit/nl/get-connector This section explains how to use `skip` and `take` parameters for paginating data. It highlights performance considerations for large `skip` values and suggests alternative methods for efficient data retrieval. ```APIDOC ## Data Retrieval with Skip and Take ### Description This section explains how to use `skip` and `take` parameters for paginating data. It highlights performance considerations for large `skip` values and suggests alternative methods for efficient data retrieval. ### Method GET ### Endpoint `/{connector}?skip={skip_value}&take={take_value}` ### Parameters #### Query Parameters - **skip** (integer) - The number of records to skip. Performance degrades significantly with values over 100,000. - **take** (integer) - The maximum number of records to return. ### Request Example ``` https://12345.rest.afas.online/ProfitRestServices/connectors/Profit_Accounts?skip=0&take=500 ``` ### Best Practices - For large datasets, avoid high `skip` values. Instead, filter data by a specific field (e.g., article, employee, booking date) and adjust the filter in each request. - Process data in smaller sets and make up to 5 simultaneous calls to improve overall processing time. - Use `skip` and `take` within these smaller sets if necessary. ``` -------------------------------- ### Partner Koppeling - Ontwikkelen Source: https://docs.afas.help/sb/nl/start Information on developing your integration using the AFAS SB REST API. This includes accessing technical documentation, understanding API concepts, and utilizing Open API specifications. ```APIDOC ## Ontwikkelen AFAS provides comprehensive technical documentation to assist in developing your integration. ### Resources: * **Technische documentatie over de SB API**: Detailed documentation for the SB API. * **Documentatie**: Explains essential concepts for all integrations. * **How-to's**: Practical examples to guide your development. * **Open API-specificaties**: Technical details for each individual API. ### API Operations: * **GET**: Read data (e.g., `GET /api/administrations`). * **POST**: Add data (e.g., `POST /api/payrolljournalentry`). * **PUT**: Add and modify data (e.g., `PUT /organisation`). * **Publiek**: APIs available for developing 'Eigen apps' (e.g., `Publiek: Relatiemanagement`). **Note**: Consider updating your integration when newer API versions become available. Refer to the [latest API specifications](link_to_latest_api_specs) for more capabilities. ``` -------------------------------- ### JSON Error Response Example (JSON) Source: https://docs.afas.help/sb/nl/authentication This is an example of an 'invalid_grant' error response from AFAS, indicating an issue with the code verifier length. It's a standard JSON format for reporting errors. ```json { "error": "invalid_grant", "error_description": "invalid code_verifier length" } ``` -------------------------------- ### JavaScript Fetch API Pagination Example Source: https://docs.afas.help/sb/nl/pagination Demonstrates how to use the Fetch API in JavaScript to make paginated and sorted requests to the AFAS API. It constructs the URL with skip, take, and sort parameters and includes authorization headers. It handles the JSON response and logs it to the console. ```javascript const url = new URL("https://demo.afasfocus.nl/Omgeving/api/endpoint"); const params = { skip: 10, take: 10, sort: "VeldNaam+descending" }; Object.keys(params).forEach(key => url.searchParams.append(key, params[key])); fetch(url, { method: "GET", headers: { "Authorization": "Bearer {your_api_key}", "Content-Type": "application/json" } }) .then(response => response.json()) .then(data => console.log(data)) ``` -------------------------------- ### JSON Error Response Example: Missing Parameters (JSON) Source: https://docs.afas.help/sb/nl/authentication This is an example of an 'invalid_request' error response from AFAS, indicating that required parameters are missing in the OAuth2.0 request. It's a standard JSON format for reporting errors. ```json { "error": "invalid_request", "error_description": "missing required request parameters" } ``` -------------------------------- ### AFAS DELETE: Remove Record by Identifier Source: https://docs.afas.help/profit/nl/update-connector This example demonstrates how to permanently delete a record from AFAS Profit using a DELETE request. The record is identified by its primary key, which is passed as a URL parameter. For example, to delete a 'KnAppointment' record with 'ApId' 123, the URL would include '/KnAppointment/ApId/123'. ```http DELETE https://12345.rest.afas.online/ProfitRestServices/connectors/KnAppointment/KnAppointment/ApId/123 ``` -------------------------------- ### Ophalen medewerkers per plan met SH_AUDIT_MdwPerPlan (JSON) Source: https://docs.afas.help/profit/nl/howto-la-sa Dit codefragment toont hoe je medewerkers ophaalt die aan specifieke plannen zijn gekoppeld. Het maakt gebruik van de SH_AUDIT_MdwPerPlan connector en filtert op meerdere 'PlanId' waarden om de relevante medewerkers te verzamelen. ```json { "skip": 0, "take": 75000, "rows": [ { "PlanId": 839, "Medewerker": "PATRICKB" }, { "PlanId": 839, "Medewerker": "OSCARG" }, { "PlanId": 839, "Medewerker": "OLGAV" }, { "PlanId": 839, "Medewerker": "OLGAS" }, { "PlanId": 839, "Medewerker": "NIELSB" }, { "PlanId": 936, "Medewerker": "JUDITHS" } ] } ``` -------------------------------- ### GET /connectors/Profit_Rooster_Ouderverlof Source: https://docs.afas.help/profit/nl/news-profit3 This endpoint retrieves information related to parental leave profit rooster. ```APIDOC ## GET /connectors/Profit_Rooster_Ouderverlof ### Description This endpoint retrieves data related to the parental leave profit rooster. ### Method GET ### Endpoint /connectors/Profit_Rooster_Ouderverlof ### Response #### Success Response (200) * **data** (array) - An array of objects containing parental leave profit rooster information. #### Response Example ```json { "data": [ { "id": 1, "name": "Example Leave", "startDate": "2023-01-01", "endDate": "2023-12-31" } ] } ``` ``` -------------------------------- ### Get Available Tasks for Dossier Items (JSON) Source: https://docs.afas.help/profit/nl/howto-workflow-acties This JSON response from the GET /Profit_Subject_Tasks endpoint lists available tasks for dossier items. It includes pagination parameters ('skip', 'take') and an array of 'rows', where each row details a task associated with a subject, including workflow and user information. This is used to determine task status and assignees. ```json { "skip": 0, "take": 20, "rows": [ { "SubjectId": 36717, "WfDescription": "Beoordeling inkooprelatie", "TaskDescription": "Ter info inkooprelatie", "User": "Diederik@ubbens.afas", "UserName": "Diederik Jacobs", "TaskId": 1000358, "WorkflowId": 1000080, "TaskName": "9AD333FD1F3B41B39054B4F733E5F045", "WorkflowName": "502095F94DA0FC07995DD8B1EBE270BF" }, { "SubjectId": 36717, "WfDescription": "Beoordeling inkooprelatie", "TaskDescription": "Ter info inkooprelatie", "User": "Yvonne@ubbens.afas", "UserName": "Yvonne Berkhout", "TaskId": 1000358, "WorkflowId": 1000080, "TaskName": "9AD333FD1F3B41B39054B4F733E5F045", "WorkflowName": "502095F94DA0FC07995DD8B1EBE270BF" } ] } ``` -------------------------------- ### GET /Profit_Subject_Attachments Source: https://docs.afas.help/profit/nl/howto-bijlage-dossier Retrieves attachments associated with a specific dossier item. This endpoint provides 'file_id' and 'subject_id' needed for the SubjectConnector. ```APIDOC ## GET /Profit_Subject_Attachments ### Description Fetches the attachments linked to a specific dossier item. It returns essential IDs for accessing the actual file content. ### Method GET ### Endpoint `https://12345.rest.afas.online/ProfitRestServices/connectors/Profit_Subject_Attachments?skip=0&take=100&filterfieldids=subject_id&filtervalues=49946&operatortypes=1` ### Parameters #### Query Parameters - **skip** (integer) - Optional - The number of records to skip. - **take** (integer) - Optional - The maximum number of records to return. - **filterfieldids** (string) - Required - The ID of the field to filter on (e.g., 'subject_id'). - **filtervalues** (string) - Required - The value to filter the specified field by (e.g., the 'SbId' from the previous step). - **operatortypes** (integer) - Required - The operator type for the filter (e.g., '1' for equals). ### Response #### Success Response (200) - **skip** (integer) - The number of records skipped. - **take** (integer) - The number of records returned. - **rows** (array) - An array of attachment objects. - **attachment_id** (integer) - Unique identifier for the attachment. - **subject_id** (integer) - The ID of the dossier item the attachment belongs to. **Required for SubjectConnector.** - **file_id** (string) - The ID of the file. **Required for SubjectConnector.** - **file_name** (string) - The name of the file. ### Response Example ```json { "skip": 0, "take": 100, "rows": [ { "attachment_id": 20175, "subject_id": 49946, "file_id": "5C055C034516ED67972E0A852E03C5B9", "file_name": "C5C8123246F1E537324F93B8D57F382D.pdf" } ] } ``` ``` -------------------------------- ### FbUnitBasicItem API Source: https://docs.afas.help/profit/nl/news-profit7 This section covers modifications to the FbUnitBasicItem connector, specifically for POST operations. Certain request properties have become optional. ```APIDOC ## POST /api/fbunitbasicitem ### Description This endpoint is for basic unit item operations. The following properties in the request body have been made optional: - `FbUnitBasicItem/Element/Fields/BiUn` - `FbUnitBasicItem/Element/Fields/ItCd` - `FbUnitBasicItem/Element/Fields/VaIt` ### Method POST ### Endpoint /api/fbunitbasicitem ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **FbUnitBasicItem/Element/Fields/BiUn** (string) - Optional - Description for BiUn field. - **FbUnitBasicItem/Element/Fields/ItCd** (string) - Optional - Description for ItCd field. - **FbUnitBasicItem/Element/Fields/VaIt** (string) - Optional - Description for VaIt field. ### Request Example ```json { "FbUnitBasicItem": { "Element": { "Fields": { "BiUn": "optional_value", "ItCd": "optional_value", "VaIt": "optional_value" } } } } ``` ### Response #### Success Response (200) (Standard success response for POST operation) #### Response Example ```json { "example": "Success response body for FbUnitBasicItem POST" } ``` ```