### Get Contacts Example (JSON) Source: https://developers.holded.com/reference/list-contacts-1 This example demonstrates how to retrieve a list of contacts from the Holded API. It shows the structure of a successful response, including details like contact ID, name, email, address, and custom fields. No specific dependencies are required beyond making an HTTP GET request. ```json { "value": [ { "id": "5aaa43d35b7064002613c048", "customId": "myReferenceId", "name": "Custom Tech Inc.", "code": "B3737387", "tradeName": "Mapple", "email": "email@mapple.com", "mobile": "63738383", "phone": "3949494", "type": "client", "iban": "ES436677378638786", "swift": "", "clientRecord": 0, "supplierRecord": 0, "billAddress": { "address": "Carrer del Mar", "city": "Barcelona", "postalCode": 8767, "province": "Barcelona", "country": "Spain", "countryCode": "ES", "info": "Random info" }, "defaults": { "salesChannel": 0, "expensesAccount": 0, "dueDays": 3, "paymentMethod": 0, "discount": 45, "language": "fr", "currency": "eur", "tax": "default", "retention": "default" }, "socialNetworks": { "website": "www.mapple.com" }, "tags": [ "tag", "otherTag" ], "notes": [ { "noteId": "5aba2365c5d43800316b2a53", "name": "My first note", "description": "An important note", "color": "primary", "updatedAt": 1522148197, "userId": "5a05cc5a60cea100094baf22" }, { "noteId": "5aba26efc5d43800316b2a54", "name": "Note", "description": "Another note", "color": "#ee575d", "updatedAt": 1522149103, "userId": "" } ], "contactPersons": [ { "personId": "5aba40fdc5d43800316b2a55", "name": "Pep", "job": "Ito", "phone": "966", "email": "noway@frog.com", "sendDocumentsByDefault": true, "linkedin": "no link" } ], "shippingAddresses": [ { "shippingId": "5aba4147c5d43800342fc4a3", "name": "Mapple shipping address", "address": "c/Lafranch", "city": "Vilafranca del Monport ", "postalCode": 899, "province": "Barcelona", "country": "Spain", "countryCode": "ES", "notes": "A public note", "privateNotes": "This is a private note, don't read it" } ], "customFields": [ { "field": "FieldOne", "value": "valueOne" } ] } ] } ``` -------------------------------- ### Get Booking by ID - Python Example Source: https://developers.holded.com/reference/get-booking This Python snippet demonstrates how to get a specific booking using its ID with the 'requests' library. It includes the necessary headers for authentication and specifies the content type. ```python import requests booking_id = '5ab11f1a3697ac00cd0a6423' api_key = 'YOUR_API_KEY' url = f"https://api.holded.com/api/crm/v1/bookings/{booking_id}" headers = { 'Content-Type': 'application/json', 'key': api_key } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error fetching booking: {response.status_code} - {response.text}") ``` -------------------------------- ### Create Product Variants JSON Example Source: https://developers.holded.com/reference/create-product-1 Example JSON payload for creating a product with variants. Requires the Inventory app to be installed. The 'kind' field must be set to 'variants' and a 'variants' array must be provided with product variant details. ```json { "kind": "variants", "variants": [ { "code":"0123i", "sku":"sku1", "subtotal":20, "cost": 5, "purchasePrice": 4, "stock": 10 } ] } ``` -------------------------------- ### Project Example Response Source: https://developers.holded.com/reference/get-project An example JSON response for a project, demonstrating the structure and typical values for its properties. ```json { "id": "5ab390311d6d82002432ec5a", "name": "Building 301", "desc": "Bulding 301 in Barcelona", "tags": [ "tag", "tog", "tug" ], "category": 0, "contactId": "5aaa51ab5b70640028340186", "contactName": "DIvero", "date": 0, "dueDate": 0, "status": 2, "lists": [ { "id": "5ab390311d6d82002432ec52", "key": "pending", "name": "Pending", "desc": "nan" }, { "id": "5ab390311d6d82002432ec53", "key": "review", "name": "Review", "desc": "nan" }, { "id": "5ab390311d6d82002432ec54", "key": "done", "name": "Done" } ] } ``` -------------------------------- ### Get Booking by ID - Node.js Example Source: https://developers.holded.com/reference/get-booking This snippet shows how to fetch a specific booking by its ID using Node.js and the 'axios' library. It configures the request with the correct URL, method, and authentication headers. ```javascript const axios = require('axios'); const bookingId = '5ab11f1a3697ac00cd0a6423'; const apiKey = 'YOUR_API_KEY'; axios.get(`https://api.holded.com/api/crm/v1/bookings/${bookingId}`, { headers: { 'Content-Type': 'application/json', 'key': apiKey } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching booking:', error); }); ``` -------------------------------- ### Get Project Summary - OpenAPI Definition Source: https://developers.holded.com/reference/get_projects-projectid-summary This OpenAPI definition describes the GET endpoint for retrieving a project summary. It specifies the path parameters, response schema, and provides an example response in JSON format. The endpoint is part of the PROJECTS tag. ```json { "openapi": "3.0.0", "info": { "title": "Projects API", "version": "1.2", "description": "The Holded’s Projects API is organized around REST, using HTTP responses code to keep you informed about what’s going on. Our endpoints will returns you metada in JSON format directly from Holded." }, "x-samples-languages": [ "curl", "node", "ruby", "python" ], "paths": { "/projects/{projectId}/summary": { "get": { "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "desc": { "type": "string" }, "projectEvolution": { "type": "object", "properties": { "tasks": { "type": "object", "properties": { "total": { "type": "integer" }, "completed": { "type": "integer" } } }, "dueDate": { "type": "integer" } } }, "profitability": { "type": "object", "properties": { "sales": { "type": "number" }, "expenses": { "type": "object", "properties": { "documents": { "type": "integer" }, "personnel": { "type": "number" }, "total": { "type": "number" } } }, "profit": { "type": "number" } } }, "economicStatus": { "type": "object", "properties": { "sales": { "type": "number" }, "quoted": { "type": "integer" }, "difference": { "type": "number" }, "estimatePrice": { "type": "integer" }, "billed": { "type": "number" }, "collected": { "type": "integer" }, "remaining": { "type": "number" } } } } }, "examples": { "response": { "value": { "name": "Building", "desc": "Bulding in Barcelona", "projectEvolution": { "tasks": { "total": 6, "completed": 3 }, "dueDate": 0 }, "profitability": { "sales": 1117.18, "expenses": { "documents": 200, "personnel": 15603.333333333, "total": 15803.333333333 }, "profit": -14686.153333333 }, "economicStatus": { "sales": 1117.18, "quoted": 34433, "difference": -33315.82, "estimatePrice": 3453456, "billed": 1351.79, "collected": 290, "remaining": 1061.79 } } } } } } } }, "tags": [ "PROJECTS" ], "description": "Get a specific project summary." }, "parameters": [ { "name": "projectId", "in": "path" } ] } } } ``` -------------------------------- ### Document Update Schema and Example (JSON) Source: https://developers.holded.com/reference/update-document-1 Defines the JSON schema for updating a document, including properties for status, info, and id. Provides an example of a successful response. ```json { "schema": { "type": "object", "properties": { "status": { "type": "integer" }, "info": { "type": "string" }, "id": { "type": "string" } } }, "examples": { "response": { "value": { "status": 1, "info": "Updated", "id": "5ac4f2cec839ea004e18a463" } } } } ``` -------------------------------- ### Get Contact Example (JSON) Source: https://developers.holded.com/reference/get-contact-1 This snippet demonstrates how to retrieve a specific contact's details using the Holded API. It includes common fields like currency, tax, social networks, tags, notes, contact persons, shipping addresses, and custom fields. The response is in JSON format. ```json { "currency": "eur", "tax": "default", "retention": "default" }, "socialNetworks": { "website": "www.mapple.com" }, "tags": [ "tag", "otherTag" ], "notes": [ { "noteId": "5aba2365c5d43800316b2a53", "name": "My first note", "description": "An important note", "color": "primary", "updatedAt": 1522148197, "userId": "5a05cc5a60cea100094baf22" }, { "noteId": "5aba26efc5d43800316b2a54", "name": "Note", "description": "Another note", "color": "#ee575d", "updatedAt": 1522149103, "userId": "" } ], "contactPersons": [ { "personId": "5aba40fdc5d43800316b2a55", "name": "Pep", "job": "Ito", "phone": "966", "email": "noway@frog.com", "sendDocumentsByDefault": true, "linkedin": "no link" } ], "shippingAddresses": [ { "shippingId": "5aba4147c5d43800342fc4a3", "name": "Mapple shipping address", "address": "c/LLafranch", "city": "Vilafranca del Monport ", "postalCode": 899, "province": "Lleida", "country": "Spain", "countryCode": "ES", "notes": "A public note", "privateNotes": "This is a private note, don't read it" } ], "customFields": [ { "field": "FieldOne", "value": "noValue" } ] } ``` -------------------------------- ### Get Project Times (Python) Source: https://developers.holded.com/reference/get-project-times This Python example demonstrates fetching time tracking data for a project. It uses the 'requests' library to perform a GET request, requiring the project ID and an API key for authentication. ```python import requests project_id = 'YOUR_PROJECT_ID' api_key = 'YOUR_API_KEY' url = f"https://api.holded.com/api/projects/v1/projects/{project_id}/times" headers = { 'Content-Type': 'application/json', 'key': api_key } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error fetching project times: {response.status_code}") ``` -------------------------------- ### Create Product Lots JSON Example Source: https://developers.holded.com/reference/create-product-1 Example JSON payload for creating a product with lots. Requires the Inventory app. Set 'kind' to 'lots' and include a 'variants' array with lot-specific details such as code, SKU, description, creation date, and end date. ```json { "kind": "lots", "variants": [ { "code":"3333test", "sku":"ps123", "desc":"my first lot", "creationDate": 1540887390, "endDate": 1546166520 } ] } ``` -------------------------------- ### Get Project Times (Node.js) Source: https://developers.holded.com/reference/get-project-times This Node.js example shows how to retrieve time tracking data for a project. It uses the 'axios' library to make a GET request to the API, requiring the project ID and an API key. ```javascript const axios = require('axios'); const projectId = 'YOUR_PROJECT_ID'; const apiKey = 'YOUR_API_KEY'; axios.get(`https://api.holded.com/api/projects/v1/projects/${projectId}/times`, { headers: { 'Content-Type': 'application/json', 'key': apiKey } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching project times:', error); }); ``` -------------------------------- ### Create Product Pack JSON Example Source: https://developers.holded.com/reference/create-product-1 Example JSON payload for creating a product pack. Requires the Inventory app. Set 'kind' to 'pack' and use the 'packItems' field to specify the products included in the pack, along with their quantities. ```json { "kind": "pack", "packItems": [ { "productId":"5bc45f5b4c4bea00183e8096", "variantId":"5bc45f5b4c4bea00183e8095", "units": 100 } ] } ``` -------------------------------- ### Get Booking by ID - Ruby Example Source: https://developers.holded.com/reference/get-booking This Ruby snippet illustrates how to retrieve a booking by its ID using the 'httparty' gem. It sets up the HTTP GET request with the appropriate headers for authentication and content type. ```ruby require 'httparty' booking_id = '5ab11f1a3697ac00cd0a6423' api_key = 'YOUR_API_KEY' response = HTTParty.get("https://api.holded.com/api/crm/v1/bookings/#{booking_id}", headers: { 'Content-Type' => 'application/json', 'key' => api_key } ) if response.success? puts response.parsed_response else puts "Error fetching booking: #{response.code} - #{response.message}" end ``` -------------------------------- ### Contact Example JSON Source: https://developers.holded.com/reference/create-contact-1 Provides a sample JSON object representing a supplier contact. It includes fields for identification, billing address, default settings, and social network information. ```json { "CustomId": "My reference", "name": "Custom Tech Inc.", "code": "B3737387", "email": "email@mapple.com", "mobile": "63738383", "phone": "3949494", "type": "supplier", "iban": "ES436677378638786", "swift": "", "clientRecord": 0, "supplierRecord": 0, "billAddress": { "address": "Carrer del Mar", "city": "Barcelona", "postalCode": 8767, "province": "Barcelona", "country": "Spain" }, "defaults": { "salesChannel": 0, "expensesAccount": 0, "dueDays": 3, "paymentMethod": 0, "discount": 45, "language": "fr", "currency": "eur", "tax": "default", "retention": "default" }, "socialNetworks": { "website": "www.mapple.com" }, "tags": [ "tag", "otherTag" ] } ``` -------------------------------- ### Create Sales Channel using Python Source: https://developers.holded.com/reference/create-sales-channel-1 Python example for creating a sales channel using the 'requests' library. This shows how to construct and send the POST request. ```python import requests import json url = "https://api.holded.com/api/invoicing/v1/saleschannels" headers = { "Content-Type": "application/json", "key": "YOUR_API_KEY" } data = { "name": "My brand new sales channel", "desc": "Main income" } try: response = requests.post(url, headers=headers, data=json.dumps(data)) response.raise_for_status() # Raise an exception for bad status codes print("Sales Channel created:", response.json()) except requests.exceptions.RequestException as e: print(f"Error creating sales channel: {e}") if e.response is not None: print("Response body:", e.response.text) ``` -------------------------------- ### List Funnels - Python Example Source: https://developers.holded.com/reference/list-funnels-1 This Python code snippet demonstrates how to get all funnels from the Holded CRM API. It uses the 'requests' library to send a GET request and includes the API key in the request headers. ```python import requests api_key = 'YOUR_API_KEY' api_url = 'https://api.holded.com/api/crm/v1/funnels' headers = { 'Content-Type': 'application/json', 'key': api_key } try: response = requests.get(api_url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print("Funnels:", response.json()) except requests.exceptions.RequestException as e: print(f"Error fetching funnels: {e}") ``` -------------------------------- ### Get Task by ID - OpenAPI Definition Source: https://developers.holded.com/reference/get-task This OpenAPI definition describes the 'Get Task' operation, allowing retrieval of a specific task using its unique ID. It specifies the request parameters, response structure, and provides an example of a successful JSON response. ```json { "openapi": "3.0.0", "info": { "title": "Projects API", "version": "1.2", "description": "The Holded’s Projects API is organized around REST, using HTTP responses code to keep you informed about what’s going on. Our endpoints will returns you metada in JSON format directly from Holded." }, "x-samples-languages": [ "curl", "node", "ruby", "python" ], "paths": { "/tasks/{taskId}": { "parameters": [ { "name": "taskId", "in": "path", "required": true, "schema": { "type": "string" } } ], "get": { "operationId": "Get Task", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "projectId": { "type": "string" }, "listId": { "type": "string" }, "name": { "type": "string" }, "desc": { "type": "string" }, "labels": { "type": "array", "items": { "type": "string" } }, "comments": { "type": "array", "items": { "type": "object", "properties": { "commentId": { "type": "string" }, "createdAt": { "type": "integer" }, "userId": { "type": "string" }, "message": { "type": "string" } } } }, "date": { "type": "integer" }, "dueDate": { "type": "integer" }, "userId": { "type": "string" }, "createdAt": { "type": "integer" }, "updatedAt": { "type": "integer" }, "status": { "type": "integer" }, "billable": { "type": "integer" }, "featured": { "type": "integer" } } }, "examples": { "response": { "value": { "id": "5ab3df6e1d6d82008c5777a4", "projectId": "5ab390311d6d82002432ec5a", "listId": "5ab390311d6d82002432ec53", "name": "Business plan", "desc": "business plan for the new project", "labels": [ "5ab390311d6d82002432ec58", "5ab390311d6d82002432ec59" ], "comments": [ { "commentId": "5ab3df8c1d6d820088525aa3", "createdAt": 1521737612, "userId": "5a05cc5a60cea100094baf22", "message": "no comments" }, { "commentId": "5ab3df971d6d82008c5777a5", "createdAt": 1521737623, "userId": "5a05cc5a60cea100094baf22", "message": "a piece of comment\n" } ], "date": 1521737582, "dueDate": 1521673200, "userId": "5a05cc5a60cea100094baf22", "createdAt": 1521737582, "updatedAt": 1521737582, "status": 0, "billable": 0, "featured": 1 } } } } } } }, "tags": [ "TASKS" ], "description": "Get a specific task." } } }, "x-samples-enabled": true, "tags": [ { "name": "TASKS" } ], "security": [ { "Auth": [] } ] } ``` -------------------------------- ### Get Document PDF using Python Source: https://developers.holded.com/reference/getdocumentpdf This Python example demonstrates fetching a document PDF. It uses the 'requests' library for HTTP communication and requires the document type, document ID, and your API key. ```python import requests def get_document_pdf(doc_type, document_id, api_key): url = f"https://api.holded.com/api/invoicing/v1/documents/{docType}/{documentId}/pdf" headers = {'key': api_key} response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes return response.json() # Example usage: # print(get_document_pdf('invoice', 'some-invoice-id', 'YOUR_API_KEY')) ``` -------------------------------- ### Update Contact API Example (JSON) Source: https://developers.holded.com/reference/update-contact-1 This example demonstrates how to update a specific contact using the Holded API. It includes fields for contact details, billing address, default settings, and social networks. The response indicates the success of the update operation. ```json { "name": "Custom Tech Inc.", "code": "B3737387", "tradeName": "Mapple", "email": "email@mapple.com", "mobile": "63738383", "phone": "3949494", "type": "client", "iban": "ES436677378638786", "swift": "UJ45623456", "clientRecord": 0, "supplierRecord": 0, "billAddress": { "address": "Carrer del Mar", "city": "Barcelona", "postalCode": 8767, "province": "Barcelona", "country": "Spain", "countryCode": "ES" }, "defaults": { "salesChannel": 0, "expensesAccount": 0, "dueDays": 3, "paymentMethod": 0, "discount": 45, "language": "fr" }, "socialNetworks": { "website": "www.mapple.com" } } ``` -------------------------------- ### Get Document PDF using Node.js Source: https://developers.holded.com/reference/getdocumentpdf This Node.js example shows how to fetch a document PDF. It utilizes the 'axios' library for making HTTP requests and requires the document type, document ID, and an API key. ```javascript const axios = require('axios'); async function getDocumentPdf(docType, documentId, apiKey) { try { const response = await axios.get(`https://api.holded.com/api/invoicing/v1/documents/${docType}/${documentId}/pdf`, { headers: { 'key': apiKey } }); return response.data; } catch (error) { console.error('Error fetching document PDF:', error); throw error; } } // Example usage: // getDocumentPdf('invoice', 'some-invoice-id', 'YOUR_API_KEY').then(data => console.log(data)); ``` -------------------------------- ### POST /products Source: https://developers.holded.com/reference/create-product-1 Create a new product. The type of product you can create depends on whether you have the Inventory app. Simple products can always be created. ```APIDOC ## POST /products ### Description Create a new product. If you don't have the Inventory app, you can only create simple products. With the Inventory app, you can create products of type 'variants', 'lots', or 'pack'. ### Method POST ### Endpoint /products ### Parameters #### Request Body - **kind** (string) - Required - The type of product ('simple', 'variants', 'lots', 'pack'). - **name** (string) - Required - The name of the product. - **desc** (string) - Optional - Description of the product. - **price** (number) - Optional - The selling price of the product. - **tax** (number) - Optional - The tax rate applicable to the product. - **cost** (number) - Optional - The cost of the product. - **calculatecost** (number) - Optional - Indicates if the cost should be calculated. - **purchasePrice** (number) - Optional - The purchase price of the product. - **tags** (array of strings) - Optional - Tags associated with the product. - **barcode** (string) - Optional - Barcode of the product. - **sku** (string) - Optional - Stock Keeping Unit for the product. - **weight** (number) - Optional - Weight of the product. - **stock** (integer) - Optional - Current stock level of the product. *For 'variants', 'lots', or 'pack' kinds, additional fields are required: - **variants** (array of objects) - Required for 'variants' kind. Each object should contain 'code', 'sku', 'subtotal', 'cost', 'purchasePrice', and 'stock'. - **variants** (array of objects) - Required for 'lots' kind. Each object should contain 'code', 'sku', 'desc', 'creationDate', and 'endDate'. - **packItems** (array of objects) - Required for 'pack' kind. Each object should contain 'productId', 'variantId', and 'units'. ### Request Example ```json { "kind": "simple", "name": "Brand new shirt" } ``` ### Response #### Success Response (201) - **status** (integer) - Status code of the operation. - **info** (string) - Information about the operation. - **id** (string) - The unique identifier of the created product. #### Response Example ```json { "status": 1, "info": "Created", "id": "5aa97e595b706400153f9f94" } ``` ``` -------------------------------- ### Update Lead - Node.js Example Source: https://developers.holded.com/reference/update-lead-1 This Node.js snippet shows how to update a lead using the 'axios' library. It constructs a PUT request to the `/leads/{leadId}` endpoint with the necessary headers and JSON body. Ensure you have 'axios' installed (`npm install axios`). ```javascript const axios = require('axios'); const leadId = '5ac4f2cec839ea004e18a463'; const apiKey = 'YOUR_API_KEY'; const leadData = { "name": "Gumersindo", "value": 48000, "dueDate": 1521646788, "customFields": [ { "field": "New", "value": "custom field" }, { "field": "other", "value": "custom field" } ], "status": 0 }; axios.put(`https://api.holded.com/api/crm/v1/leads/${leadId}`, leadData, { headers: { 'Content-Type': 'application/json', 'key': apiKey } }) .then(response => { console.log('Lead updated successfully:', response.data); }) .catch(error => { console.error('Error updating lead:', error.response ? error.response.data : error.message); }); ``` -------------------------------- ### GET /products/{productId}/image Source: https://developers.holded.com/reference/get-product-image Retrieves the main image for a given product ID. ```APIDOC ## GET /products/{productId}/image ### Description Get the main image of a specific product. ### Method GET ### Endpoint /products/{productId}/image ### Parameters #### Path Parameters - **productId** (string) - Required - The ID of the product for which to retrieve the image. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) (The response for this endpoint is typically an image file, not JSON. The OpenAPI definition shows an empty JSON schema for the 200 response, implying the content type would be something like `image/jpeg` or `image/png`.) #### Response Example (Binary image data) ``` -------------------------------- ### Create Product API Definition (OpenAPI) Source: https://developers.holded.com/reference/create-product-1 The OpenAPI definition for the product creation endpoint. It outlines the request body parameters, including 'kind', 'name', 'price', 'stock', and optional fields for variants, lots, or packs. Also details the response structure. ```json { "openapi": "3.0.0", "info": { "title": "Invoice API", "version": "1.4", "description": "The Holded's Invoicing API is organized around REST, using HTTP responses code to keep you informed about what's going on. Our endpoints will returns you metada in JSON format directly from Holded." }, "x-samples-languages": [ "curl", "node", "ruby", "python" ], "paths": { "/products": { "post": { "operationId": "Create Product", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "kind": { "type": "string" }, "name": { "type": "string" }, "desc": { "type": "string" }, "price": { "type": "number" }, "tax": { "type": "number" }, "cost": { "type": "number" }, "calculatecost": { "type": "number" }, "purchasePrice": { "type": "number" }, "tags": { "type": "array", "items": { "type": "string" } }, "barcode": { "type": "string" }, "sku": { "type": "string" }, "weight": { "type": "number" }, "stock": { "type": "integer" } } } } }, "x-examples": { "application/json": {}, "new": { "kind": "simple", "name": "Brand new shirt" } } }, "responses": { "201": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "integer" }, "info": { "type": "string" }, "id": { "type": "string" } } }, "examples": { "response": { "value": { "status": 1, "info": "Created", "id": "5aa97e595b706400153f9f94" } } } } } } }, "tags": [ "PRODUCTS" ], "summary": "Create Product" } } }, "tags": [ { "name": "PRODUCTS" } ], "security": [ { "Auth": [] } ], "servers": [ { "url": "https://api.holded.com/api/invoicing/v1" } ], "components": { "securitySchemes": { "Auth": { "type": "apiKey", "name": "key", "in": "header" } } }, "x-readme": { "explorer-enabled": true, "proxy-enabled": true } } ``` -------------------------------- ### Get Booking by ID - cURL Example Source: https://developers.holded.com/reference/get-booking This snippet demonstrates how to retrieve a specific booking using its ID via a cURL request. It includes the necessary authentication header. ```curl curl -X GET https://api.holded.com/api/crm/v1/bookings/5ab11f1a3697ac00cd0a6423 \ -H "Content-Type: application/json" \ -H "key: YOUR_API_KEY" ``` -------------------------------- ### Create Sales Channel using Node.js Source: https://developers.holded.com/reference/create-sales-channel-1 Node.js example for creating a sales channel. It demonstrates making a POST request to the Holded API using the 'axios' library. ```javascript const axios = require('axios'); const createSalesChannel = async (name, desc) => { try { const response = await axios.post('https://api.holded.com/api/invoicing/v1/saleschannels', { name: name, desc: desc }, { headers: { 'Content-Type': 'application/json', 'key': 'YOUR_API_KEY' } }); console.log('Sales Channel created:', response.data); return response.data; } catch (error) { console.error('Error creating sales channel:', error.response ? error.response.data : error.message); throw error; } }; // Example usage: // createSalesChannel('My brand new sales channel', 'Main income'); ``` -------------------------------- ### Update Lead - Python Example Source: https://developers.holded.com/reference/update-lead-1 This Python snippet demonstrates updating a lead using the 'requests' library. It sends a PUT request to the `/leads/{leadId}` endpoint, including the API key in the headers and the lead data as a JSON payload. Ensure you have the 'requests' library installed (`pip install requests`). ```python import requests import json lead_id = '5ac4f2cec839ea004e18a463' api_key = 'YOUR_API_KEY' url = f'https://api.holded.com/api/crm/v1/leads/{lead_id}' lead_data = { "name": "Gumersindo", "value": 48000, "dueDate": 1521646788, "customFields": [ { "field": "New", "value": "custom field" }, { "field": "other", "value": "custom field" } ], "status": 0 } headers = { 'Content-Type': 'application/json', 'key': api_key } response = requests.put(url, headers=headers, data=json.dumps(lead_data)) if response.status_code == 200: print(f"Lead updated successfully: {response.json()}") else: print(f"Error updating lead: {response.status_code} - {response.text}") ``` -------------------------------- ### GET /projects Source: https://developers.holded.com/reference/list-projects Retrieves a list of all projects associated with the authenticated account. This endpoint allows fetching project details such as ID, name, description, tags, and associated financial documents. ```APIDOC ## GET /projects ### Description Retrieves a list of all projects associated with the authenticated account. This endpoint allows fetching project details such as ID, name, description, tags, and associated financial documents. ### Method GET ### Endpoint /projects ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of projects to return. - **offset** (integer) - Optional - The number of projects to skip before starting to collect the result set. - **sort** (string) - Optional - The field to sort the projects by. Possible values: `name`, `date`, `dueDate`. - **order** (string) - Optional - The order of sorting. Possible values: `asc`, `desc`. ### Request Example ```json { "example": "No request body needed for GET request." } ``` ### Response #### Success Response (200) - **data** (array) - An array of project objects. - **id** (string) - The unique identifier of the project. - **name** (string) - The name of the project. - **desc** (string) - A description of the project. - **tags** (array of strings) - Tags associated with the project. - **category** (integer) - The category ID of the project. - **contactId** (string) - The ID of the associated contact. - **contactName** (string) - The name of the associated contact. - **date** (integer) - The creation date of the project (Unix timestamp). - **dueDate** (integer) - The due date of the project (Unix timestamp). - **status** (integer) - The status of the project. - **lists** (array of objects) - Lists associated with the project. - **listId** (string) - The ID of the list. - **key** (string) - The key of the list. - **name** (string) - The name of the list. - **desc** (string) - The description of the list. - **billable** (integer) - Indicates if the project is billable (1 for yes, 0 for no). - **expenses** (object) - Details about expenses associated with the project. - **docId** (string) - The ID of the expense document. - **type** (string) - The type of expense. - **subtotal** (integer) - The subtotal of the expense. - **desc** (string) - The description of the expense. - **invoiceNum** (string) - The invoice number for the expense. - **total** (integer) - The total amount of the expense. - **contactId** (string) - The ID of the contact for the expense. - **contactName** (string) - The name of the contact for the expense. - **date** (integer) - The date of the expense (Unix timestamp). - **dueDate** (integer) - The due date of the expense (Unix timestamp). - **estimates** (array of objects) - Details about estimates associated with the project. - **docId** (string) - The ID of the estimate document. - **type** (string) - The type of estimate. - **subtotal** (integer) - The subtotal of the estimate. - **desc** (string) - The description of the estimate. - **invoiceNum** (string) - The invoice number for the estimate. - **total** (number) - The total amount of the estimate. - **contactId** (string) - The ID of the contact for the estimate. - **contactName** (string) - The name of the contact for the estimate. - **date** (integer) - The date of the estimate (Unix timestamp). - **dueDate** (integer) - The due date of the estimate (Unix timestamp). #### Response Example ```json { "data": [ { "id": "5ab390311d6d82002432ec55", "name": "Project Alpha", "desc": "Initial development phase.", "tags": ["development", "testing"], "category": 1, "contactId": "5a1b2c3d4e5f6a7b8c9d0e1f", "contactName": "Client Corp", "date": 1678886400, "dueDate": 1681564800, "status": 0, "lists": [ { "listId": "5ab390311d6d82002432ec55", "key": "todo", "name": "To Do", "desc": "Tasks to be completed" } ], "billable": 1, "expenses": { "docId": "exp_12345", "type": "invoice", "subtotal": 500, "desc": "Consulting fees", "invoiceNum": "INV-001", "total": 600, "contactId": "5a1b2c3d4e5f6a7b8c9d0e1f", "contactName": "Client Corp", "date": 1678886400, "dueDate": 1681564800 }, "estimates": [ { "docId": "est_67890", "type": "quote", "subtotal": 1000, "desc": "Development proposal", "invoiceNum": "EST-001", "total": 1200, "contactId": "5a1b2c3d4e5f6a7b8c9d0e1f", "contactName": "Client Corp", "date": 1678886400, "dueDate": 1681564800 } ] } ] } ``` ``` -------------------------------- ### Update Document Pipeline - Node.js Source: https://developers.holded.com/reference/update-document-pipeline This Node.js example shows how to update a document's pipeline using the Holded API. It utilizes the 'node-fetch' library to make a POST request to the relevant endpoint, sending the document ID, type, and pipeline stage in the request. Ensure you have 'node-fetch' installed (`npm install node-fetch`). ```javascript const fetch = require('node-fetch'); async function updatePipeline(docType, documentId, pipelineStage, apiKey) { const url = `https://api.holded.com/api/invoicing/v1/documents/${docType}/${documentId}/pipeline/set`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'key': apiKey }, body: JSON.stringify({ pipeline: pipelineStage }) }); return await response.json(); } // Example usage: // updatePipeline('salesorder', 'YOUR_DOCUMENT_ID', 'your_pipeline_stage', 'YOUR_API_KEY') // .then(data => console.log(data)) // .catch(error => console.error('Error:', error)); ```