In modules 2 and 3 the exercises consisted of creating infrastructure with commands: a virtual machine and a web application. In SaaS there is nothing to deploy, and that is precisely why this exercise is different: you are going to step into Laura's and Jordi's shoes and go through, from start to finish, the life of a SaaS application in a company. You will create a free account with the CRM chosen as the prototype in Popular SaaS Providers (HubSpot), configure it for Hortalia, create users, import a fictional customer base, build the shops pipeline, log a deal and an activity, create a report, switch on two-step verification, query the data through the API, export it as an exit plan and, at the end, delete the account. By the time you finish you will have practised everything that "still belongs to the customer" in SaaS: configuration, identities, data, integrations and the way out.
- Before you start: requirements and lab rules
1.1 What you need
| Requirement | Detail |
|---|---|
| An up-to-date browser | Any of the usual ones |
| A test email address | An address that is neither your company's nor your main personal one. If your email provider supports + aliases (for example, yourname+hortalia@...), you can use them to create several test users |
| A phone with an authenticator app | Microsoft Authenticator, Google Authenticator or similar (step 9) |
| A spreadsheet or a text editor | To prepare the CSV (step 5) |
Optional: a terminal with curl and Python 3 |
For step 10 (pip install requests) |
| Estimated time | 2-3 hours |
1.2 Lab rules
- Fictional data only. No real customers and no personal data belonging to anyone. All the data in this exercise uses
.exampledomains, which are reserved for examples. - The interface changes. SaaS products update their interface frequently (remember the continuous updates in Definition and Characteristics of SaaS). That is why the steps are described by functionality ("in the account settings, the defaults section"), not by the exact position of the buttons. If you cannot find something, use the settings search box or the product's help with the name of the feature.
- The free plan has limits. The number of users, pipelines, custom properties, reports or automations may be limited or require a paid plan. When a step is not available in your account, write it down: that note is a result of the prototype that Laura and Sara will use in module 5.
- If you use another CRM (Pipedrive, Zoho CRM, a Dynamics 365 Sales trial), the steps are equivalent under other names; step 10 would use a different API.
1.3 What you are going to build
flowchart LR
CSV["customers_hortalia.csv<br/>(14 fictional customers)"] --> IMP["Import"]
IMP --> CRM["Test CRM account<br/>Europe/Madrid · EUR"]
CRM --> PIP["Shops pipeline<br/>6 stages"]
CRM --> INF["Report and dashboard"]
CRM --> API["API with a private<br/>app token"]
CRM --> EXP["CSV export<br/>(exit plan)"]
EXP --> DEL["Deletion of the account"]
- Step 1: create the test account
- Go to the HubSpot website and look for the free CRM option ("Get started free" or similar).
- Sign up with your test email address. Avoid signing up with a Google or Microsoft account belonging to your company: it would create a link with your corporate identity that you do not need for the lab.
- In the initial wizard, give "Hortalia Test" as the company and a fictional website such as
hortalia.exampleif it asks for one. Answer the rest of the questions (sector, size, role) with generic values; they only serve to tailor the welcome screen. - Data location: if the wizard lets you choose where the account is hosted, choose the European Union. Once you are in, look at the address in the browser: accounts hosted in the European data center usually show a region indicator such as
app-eu1.hubspot.com. Write down what you see. - If the wizard offers to connect your email, import contacts or install extensions, skip it for now.
Why point 4 matters: the data location is usually fixed when the account is created and cannot always be changed afterwards. In a real deployment it is a decision taken before signing up, using the criteria in Security and Regulatory Compliance by Model.
- Step 2: configure the account for Hortalia
Open the settings (usually the gear icon) and look for the account defaults section.
| Setting | Value for Hortalia | Why |
|---|---|---|
| Account name | Hortalia Test | To tell it apart from a future real account |
| Time zone | (GMT+01:00) Europe/Madrid | The dates of tasks, meetings and reports must be in Madrid time, with automatic daylight saving |
| Company currency | EUR (euro) | Deal amounts are recorded in euros. Set it before creating deals; changing it later may not be allowed or may complicate the reports |
| Date and number format | Spanish (day/month/year, decimal comma) | Avoids confusion between 03/04 (3 April) and 04/03 |
| Your user's language | Spanish | It is in your profile preferences, not the account's: each user chooses their own language |
Notice the difference between account settings (which affect everyone: time zone, currency) and user settings (language, signature, notifications). It is the same separation as in any SaaS product: the administrator sets what is common and each person adjusts their own.
Check: create a test task for tomorrow at 9:00 and verify that it appears at that time in your task calendar. Delete it afterwards.
- Step 3: users, permissions and team
In the settings, look for Users and teams.
- Invite a second user to represent Jordi, using an alias of your test address (for example,
yourname+jordi@...). Accept the invitation from that mailbox in a private browser window. - Review the permissions available. Free plans usually have few levels (for example, super admin and basic permissions per tool); detailed permission sets, teams and "my records only" visibility are usually on paid plans. Give "Jordi" edit access to contacts, companies and deals, without account administration or export permissions, if your plan allows it.
- Try to create a team called "Shop sales". If it is not available, write that down.
- Write down the maximum number of users your free plan allows (the screen itself or the plans page will say).
| What Hortalia would want | Available on your plan? (fill in) | Implication |
|---|---|---|
| 9 users (Jordi + 8 sales reps) | If not, a paid plan with per-user licenses will be needed | |
| Each sales rep sees only their own customers | Protection against the whole customer base leaking | |
| A "Shop sales" team | Reports per team | |
| Preventing non-administrators from exporting | Data governance (Integration, Identity, and Governance) | |
| SSO with Entra ID | Usually on higher plans |
This table is one of the prototype's deliverables.
- Step 4: a custom property for the customer type
Hortalia distinguishes between shops and individuals. In the settings, look for Properties and, on the Contacts object, create a new property:
| Field | Value |
|---|---|
| Label | Tipo de cliente |
| Internal name | tipo_de_cliente (usually generated automatically from the label; write it down, you will use it in step 10) |
| Group | Información del contacto |
| Field type | Dropdown select |
| Options | Label Shop → internal value Shop; label Individual → internal value Individual |
Two concepts that appear in every SaaS product:
- Label versus internal name: the label is what people see and it can be translated or changed; the internal name is what the import and the API use, and it does not change. That is why integrations must never depend on labels.
- This is configuration, not customisation (section 7 of Definition and Characteristics of SaaS): it is done without programming and it survives the product's updates.
- Step 5: import the customer base from a CSV
6.1 The file
Create a text file called customers_hortalia.csv with exactly this content (14 fictional customers: 9 shops and 5 individuals):
Nombre,Apellidos,Email,Telefono,Ciudad,Tipo de cliente,Estado del ciclo de vida,Empresa,Dominio de la empresa
Anna,Martínez Gil,[email protected],+34 600 000 101,Valencia,Shop,customer,Martínez Greengrocers,martinezgreengrocers.example
Peter,Núñez Roca,[email protected],+34 600 000 102,Castellón de la Plana,Shop,customer,Peter's Garden,petersgarden.example
Lucy,Ferrer Soler,[email protected],+34 600 000 103,Alicante,Shop,customer,Neighbourhood Market,neighbourhoodmarket.example
Xavier,Ortega Peña,[email protected],+34 600 000 104,Murcia,Shop,lead,Ortega Grocers,ortegagrocers.example
Carmen,Ibáñez Mora,[email protected],+34 600 000 105,Madrid,Shop,lead,The Green Basket,thegreenbasket.example
Sergio,López Vidal,[email protected],+34 600 000 106,Tarragona,Shop,lead,Vidal Fruits,vidalfruits.example
Marina,Cano Ruiz,[email protected],+34 600 000 107,Zaragoza,Shop,customer,Market Fresh Foods,marketfresh.example
Raul,Serrano Pastor,[email protected],+34 600 000 108,Albacete,Shop,lead,Serrano Eco Shop,serranoecoshop.example
Elena,Muñoz Castro,[email protected],+34 600 000 109,Valencia,Shop,customer,Elena's Greengrocer,elenasgreengrocer.example
Thomas,García Beltrán,[email protected],+34 600 000 201,Valencia,Individual,customer,,
Nuria,Sanz Molina,[email protected],+34 600 000 202,Madrid,Individual,customer,,
Óscar,Prieto León,[email protected],+34 600 000 203,Seville,Individual,lead,,
Isabel,Romero Díaz,[email protected],+34 600 000 204,Bilbao,Individual,customer,,
Andrew,Vega Campos,[email protected],+34 600 000 205,Barcelona,Individual,lead,,How it is built:
- First row: the headers. One column per piece of data. The names are free; what matters is assigning them to CRM properties afterwards (the mapping).
- Separator: a comma. That is why no value contains a comma. If you needed a comma inside a value (for example, "Martínez, S.L."), you would put it in double quotes.
- Encoding: UTF-8. Essential so that the accents and the ñ (
Núñez,Óscar,Muñoz) are imported correctly. Tipo de cliente: uses exactly the internal values of the property from step 4 (Shop,Individual).Estado del ciclo de vida: uses the internal values of that standard property (customerfor a customer,leadfor a prospect), which do not depend on the language of the interface. Check the exact values for your account in the property itself.- Company and domain: only the shops have them. Individuals leave those two columns empty (
,,at the end). The CRM will use the domain to create the company and associate the contact with it, and to avoid duplicating it if it already exists. - Phone numbers in international format (
+34 ...): stops the CRM misreading the country code.
6.2 The import, step by step
- Look for the Import feature (usually under Contacts or in the settings, under "Import and export").
- Choose to import from a file on your computer, one file and multiple objects (contacts and companies), because each row contains data for both and we want them to end up associated.
- Upload
customers_hortalia.csv. - Map the columns. Check that the wizard assigns each column to the right object and property:
| CSV column | Object | CRM property |
|---|---|---|
| Nombre | Contact | Nombre (First name) |
| Apellidos | Contact | Apellidos (Last name) |
| Contact | Correo electrónico (the contact deduplication key) | |
| Telefono | Contact | Número de teléfono |
| Ciudad | Contact | Ciudad |
| Tipo de cliente | Contact | Tipo de cliente (the property from step 4) |
| Estado del ciclo de vida | Contact | Estado del ciclo de vida |
| Empresa | Company | Nombre de la empresa |
| Dominio de la empresa | Company | Nombre de dominio de la empresa (the company deduplication key) |
- If the wizard asks what to do with existing records, choose create and update.
- Give the import a recognisable name ("Hortalia customers – test 1") and run it.
- Review the result: the CRM will show how many records were created, updated or failed, and will let you download an error file. You should end up with 14 contacts and 9 companies, with each shop associated with its contact.
Check: open the company "Martínez Greengrocers" and verify that Anna Martínez appears associated with it. Open Thomas García and verify that he has no company and that his customer type is Individual.
6.3 Typical import errors
| Symptom | Cause | Fix |
|---|---|---|
Núñez instead of Núñez |
The file was saved with a different encoding (for example, the ANSI/Windows-1252 used by some versions of Excel) | Save it as "CSV UTF-8" in Excel, or choose UTF-8 in your editor |
| Everything appears in a single column | Excel with Spanish regional settings saves CSVs with a semicolon as the separator | Change the separator to a comma, or import as Excel (.xlsx), which the CRM also accepts |
| Duplicate contacts | The same customer with different email addresses, or rows with no email | Clean the file first; the CRM deduplicates by email, not by name |
| Duplicate companies | Rows with no domain or with domains written in different ways (www., capitals) |
Normalise the domain |
| "Invalid value" in the customer type | The value in the CSV does not match the property's options (shop in lower case, Shops) |
Use exactly the internal values |
| The lifecycle stage is not imported | A value in another language or misspelled | Use the property's internal values |
| Owner not assigned | A "Sales rep" column with names that do not correspond to CRM users | The owner column must contain the email address of an existing user |
| Numbers with the country code lost | Excel turned +34 600... into a number and removed the + |
Format the column as text before saving |
Tip: in a real migration, import five test rows first, check the result and only then import the rest. Undoing a badly mapped bulk import costs far more.
- Step 6: the shops sales pipeline
In SaaS Use Cases, Jordi defined the stages of the shops pipeline. In the settings, look for Objects → Deals → Pipelines.
- The free plan usually includes a single pipeline, already created with stages in English. Instead of creating a new one, rename it to "Shops".
- Edit the stages so that they look like this:
| Order | Stage | Close probability | Type |
|---|---|---|---|
| 1 | First contact | 10% | Open |
| 2 | Visit made | 20% | Open |
| 3 | Proposal sent | 40% | Open |
| 4 | Trial order | 70% | Open |
| 5 | Won | 100% | Closed won |
| 6 | Lost | 0% | Closed lost |
- Rename the existing "won" and "lost" stages instead of deleting them and creating others. The reason: each stage has an internal identifier that does not change when it is renamed. The function we designed in Integration, Identity, and Governance of SaaS Applications expected the value
closedwon; if you delete that stage and create another one, it will have a different identifier and the integration would stop working. It is the same "label versus internal name" principle from step 4. - If you can, add a mandatory "Loss reason" property (price, competition, quality, other) to the "Lost" stage.
- Step 7: log a deal and an activity
8.1 The deal
Create a deal with these details:
| Field | Value |
|---|---|
| Name | Martínez Greengrocers – weekly order |
| Pipeline | Shops |
| Stage | Trial order |
| Amount | 3,200 (EUR) |
| Expected close date | Two weeks from now |
| Associated company | Martínez Greengrocers |
| Associated contact | Anna Martínez Gil |
Create two more deals of your own choosing, at different stages (for example, "The Green Basket – first visit" at First contact, €800, and "Ortega Grocers – proposal" at Proposal sent, €1,500). They will come in handy for the report.
8.2 The activity
On Anna Martínez's record:
- Log a call that has already taken place: "Trial order confirmed. She wants deliveries on Tuesdays before 8:00". Outcome: connected.
- Create a task for "Jordi" (or for yourself): "Call Anna to close the weekly order", due in a week's time at 10:00.
- Go back to the deal and move it to the Won stage (by dragging it in the board view or by editing the stage).
Check: the company's record should show the call, the task and the stage change in its timeline. This is what the spreadsheet could never provide: the history of the relationship, shared by the whole team. If the webhook from 04-04 were configured, this stage change with an amount of €3,200 would have alerted the warehouse.
- Step 8: a simple report and dashboard
Look for the Reports → Dashboards section.
- Check whether your account includes a default sales dashboard; open it and look at the reports it comes with.
- Create a new report (or customise an existing one) with the deal amount by stage of the Shops pipeline, as a bar or funnel chart.
- Create a second report with the number of contacts by customer type (your
tipo_de_clienteproperty), as a pie or bar chart. - Add both to a dashboard called "Hortalia Sales".
- Write down any limits you come across (number of dashboards, reports per dashboard, custom reports).
| Report | Expected result with the exercise's data |
|---|---|
| Amount by stage | Won: €3,200; Proposal sent: €1,500; First contact: €800 (depending on the deals you created) |
| Contacts by customer type | Shop: 9; Individual: 5 |
This dashboard is what Jordi wanted every Monday without having to ask one by one.
- Step 9: switch on two-step verification
- In your profile and preferences, in the security section, switch on two-step verification with your authenticator app: scan the QR code and type in the six-digit code it generates.
- Save the recovery codes somewhere safe (a password manager), not on the same phone.
- As an administrator, look in the account security settings for the option to require two-step verification for all users. Switch it on if it is available on your plan and check that the "Jordi" user has to set it up at their next sign-in.
- Sign out and sign back in to check that you are asked for the second factor.
In Hortalia's real account, the ideal would be SSO with Entra ID, with MFA and Conditional Access enforced in Entra ID (Integration, Identity, and Governance of SaaS Applications). As long as the plan does not include SSO, the CRM's own two-step verification is the minimum measure, and it has to be required of everyone, not merely recommended.
- Step 10: query the data through the API
11.1 Create a private app with a token
HubSpot lets administrators create private apps: internal integrations with an access token and a specific set of scopes. The location of this feature has changed in recent versions of the developer platform (it may appear in the settings as "Private apps" or in a development section as legacy apps); search for "private app" in the settings or check the current documentation. If your plan does not allow you to create one, read this step and continue with step 11.
- Create a private app called "Hortalia CRM read – lab".
- Grant only these read scopes:
crm.objects.contacts.read,crm.objects.companies.readandcrm.objects.deals.read. - Create the app and copy the access token. Treat it like a password.
- In your terminal, store it in an environment variable (not in a file in the project):
11.2 A first query with curl
curl -s "https://api.hubapi.com/crm/v3/objects/contacts?limit=5&properties=firstname,lastname,email,tipo_de_cliente" \
-H "Authorization: Bearer $TOKEN_CRM" | python3 -m json.tool/crm/v3/objects/contacts: the contacts resource of the CRM's v3 API.limit=5: five contacts per page.properties=...: which properties to return. If you do not ask for them, the API only returns a handful by default. Notice that the internal nametipo_de_clienteis used, not the label.Authorization: Bearer $TOKEN_CRM: the private app's token.| python3 -m json.tool: formats the JSON so that it is easier to read.
Response (abbreviated):
{
"results": [
{
"id": "70123456001",
"properties": {
"firstname": "Anna",
"lastname": "Martínez Gil",
"email": "[email protected]",
"tipo_de_cliente": "Shop"
},
"createdAt": "2026-09-22T08:15:03.120Z",
"archived": false
}
],
"paging": { "next": { "after": "70123456006" } }
}results: the list of contacts; each with its internalidand itsproperties.paging.next.after: if it exists, there are more results; you ask for them by adding&after=70123456006to the next call. The dates come in UTC (the trailingZ), even though the account is set to Europe/Madrid: APIs usually work in UTC and the conversion is done by whoever presents the data.
Now try what happens if you ask for something the token does not have permission for, such as creating a contact:
curl -s -X POST "https://api.hubapi.com/crm/v3/objects/contacts" \
-H "Authorization: Bearer $TOKEN_CRM" -H "Content-Type: application/json" \
-d '{"properties": {"email": "[email protected]"}}'You should get a permissions error (HTTP code 403 with a message about the scopes). That is least privilege at work: the token can only read.
11.3 A Python script: shops in the CRM
This script lists all the shops, going through the pages, using the search API to filter by customer type:
import os
import requests
URL = "https://api.hubapi.com/crm/v3/objects/contacts/search"
HEADERS = {"Authorization": f"Bearer {os.environ['TOKEN_CRM']}"}
query = {
"filterGroups": [{
"filters": [{"propertyName": "tipo_de_cliente", "operator": "EQ", "value": "Shop"}]
}],
"properties": ["firstname", "lastname", "email", "city"],
"limit": 100,
}
shops = []
while True:
response = requests.post(URL, headers=HEADERS, json=query, timeout=15)
response.raise_for_status()
data = response.json()
shops.extend(data["results"])
next_page = data.get("paging", {}).get("next", {}).get("after")
if not next_page:
break
query["after"] = next_page
print(f"Shops in the CRM: {len(shops)}")
for s in sorted(shops, key=lambda c: c["properties"].get("city") or ""):
p = s["properties"]
print(f" {p.get('city') or '-':22} {p['firstname']} {p['lastname']:18} {p['email']}")Explanation:
/contacts/search: the search API receives aPOSTwith the criteria in JSON, instead of parameters in the URL.filterGroups/filters: filters within the same group are combined with "AND"; several groups, with "OR". Here there is a single filter:tipo_de_clienteequal (EQ) toShop.properties: the properties we want in the response.- The
while Trueloop: asks for a page, accumulates the results inshopsand, if the response brings apaging.next.after, adds it to the query to ask for the next one. With 9 shops one page will be enough, but the script would work just the same with 9,000 (within the search API's limits, which are worth checking). raise_for_status(): if the API responds with an error (expired token, permissions), the script stops with a clear message instead of carrying on with empty data.- The output sorts the shops by city. Expected result:
Shops in the CRM: 9.
Warning: APIs have call limits per second and per day that depend on the plan. A script that goes through thousands of records has to respect them (and retry after a wait if it receives a 429 code).
- Step 11: export the data (exit plan)
In Integration, Identity, and Governance of SaaS Applications we set out the rule: no SaaS product goes into production without a tested export. Test it now.
- In the Contacts view, with all the contacts showing, look for the Export option. Choose CSV format, include all the properties and, if it offers them, the associations.
- Repeat with Companies and Deals.
- The CRM usually prepares the export in the background and emails you a download link with an expiry date. Download it.
- Open the files and check: are all 14 contacts there with their accents intact? Does the customer type appear? Can you see the company associated with each contact? Do the deals have an amount, a stage and a date?
- Fill in the prototype's exit sheet:
| Exit plan question | Result of your test |
|---|---|
| Are contacts, companies and deals exported? | |
| Are the associations between them preserved? | |
| Are activities (calls, tasks, notes) exported? How? | |
| What is not exported? (pipeline configuration, reports, properties, automations) | |
| Can the export be automated through the API? | Yes, with scripts like the one in step 10 (extending them to every object) |
| Total time for the test |
The configuration (stages, properties, reports) is almost never exported in a format another product can import. Document it (with screenshots or a table) so that it can be rebuilt in another CRM. This sheet feeds straight into the vendor lock-in assessment in Cloud Migration.
- Step 12: delete the test account
When you have finished (and done the extension exercises, if you want to), clean up the lab in this order:
- Revoke the token: delete the private app. A forgotten token is an open door, even in a test account.
- Remove any integrations you connected (email, calendar, extensions).
- Delete the exported files from your computer if you do not need them: even though they are fictional, it is a good habit.
- Delete the account: the account settings usually have an option to cancel or delete the account (search the help for "delete account"). Read carefully what is deleted and within what period.
- Delete your user if the platform manages it separately from the account (you can belong to several accounts with the same user).
- Delete the environment variable:
unset TOKEN_CRM(Linux/macOS) orRemove-Item Env:TOKEN_CRM(PowerShell).
Reflection: cancelling a SaaS product is part of its lifecycle. Write down how long it took you to find the delete option: that is another data point about the provider.
Common Mistakes and Tips
- Signing up with your corporate account "to be quicker". You mix a lab with your company identity and you may create an ungoverned SaaS product. Use a test email address.
- Setting the currency or the time zone after creating data. Some settings are hard or impossible to change later. Configure the account before importing.
- Saving the CSV from Excel without choosing "CSV UTF-8". Broken accents and the wrong separator are the number one cause of failed imports.
- Deleting stages or properties instead of renaming them. The internal identifiers change and integrations and reports break.
- Granting the token every scope "just in case". If the token leaks, the damage is proportional to its permissions.
- Pasting the token into a script or a chat. Environment variables or a secrets store, always. If it leaks, revoke it immediately and create another one.
- Leaving the test account open. Forgotten data, users and tokens are security debt.
- Tip: keep the tables you have filled in (permissions available, plan limits, exit sheet). They are the evidence from the prototype and they will be used in module 5 to compare the CRM with its alternatives.
Exercises
Exercise 1 (integration with Microsoft 365 email). Jordi wants the emails that sales reps exchange with shops from Outlook to be logged on the customer's record in the CRM. Research in the CRM's documentation what options exist (inbox connection, Outlook extension) and answer: a) what permissions the integration asks for over the mailbox; b) what Laura should review in Entra ID before allowing it; c) what data protection risk appears when emails are logged automatically.
Exercise 2 (lead capture form). Hortalia wants to capture individuals interested in its weekly fruit box through a form on the website. Design (and, if your plan allows it, create) a CRM form with the minimum fields needed, say what value the tipo_de_cliente property should take automatically for contacts arriving through it and what legal text must accompany it.
Exercise 3 (simple automation through the API). When an individual signs up on the hortalia-shop store, Marc wants them added to the CRM. Write a Python script that creates a contact with POST /crm/v3/objects/contacts and that, if the contact already exists (same email), does not fail but reports it. Say which scope the token needs and why it is not a good idea to add it to the read token from step 10.
Solutions
Solution 1. a) Email integrations usually ask, through OAuth 2.0, for delegated permissions to read (and sometimes send) the email and calendar of the user who connects them; the exact scope appears on the consent screen and in the documentation. b) Laura should review in Entra ID the enterprise application that is created when consent is given: what permissions it requests, whether it requires administrator consent (which is what you want, restricting user consent as we saw in 04-04), and restrict it to the "Sales team" group. c) Emails that may contain personal data or information unrelated to customers (personal or internal emails) would be logged in a third-party system. It is advisable to configure exclusions (internal domains, personal senders), inform employees and review the legal basis in Security and Regulatory Compliance by Model. Common mistake: letting each sales rep connect their mailbox without Laura having reviewed the application: that is shadow IT inside an approved SaaS product.
Solution 2. Minimum fields: name, email address, postcode (to know whether Hortalia delivers in the area) and, optionally, a phone number. Asking for less data increases conversions and complies with the data minimisation principle. In the form's settings, tipo_de_cliente is added as a hidden field with the value Individual, and the lifecycle stage as lead. Legal text: basic data protection information (controller, purpose, rights, a link to the privacy policy) and a checkbox that is not ticked by default to accept marketing communications, separate from the form submission. The exact wording must be validated by the person responsible for data protection. Tip: create a list or view called "Individuals from the web form" to measure how many arrive this way.
Solution 3.
import os
import requests
URL = "https://api.hubapi.com/crm/v3/objects/contacts"
HEADERS = {"Authorization": f"Bearer {os.environ['TOKEN_CRM_ESCRITURA']}"}
def add_individual(first_name: str, last_name: str, email: str, city: str) -> None:
body = {"properties": {
"firstname": first_name, "lastname": last_name, "email": email, "city": city,
"tipo_de_cliente": "Individual", "lifecyclestage": "lead",
}}
r = requests.post(URL, headers=HEADERS, json=body, timeout=15)
if r.status_code == 201:
print(f"Created: {email} (id {r.json()['id']})")
elif r.status_code == 409:
print(f"A contact with {email} already existed; nothing was duplicated")
else:
r.raise_for_status()
add_individual("Laia", "Puig Serra", "[email protected]", "Girona")201 Created: the contact has been created; the response includes itsid.409 Conflict: the CRM rejects the creation because a contact with that email already exists (the same deduplication by email as in the import). The script reports it instead of failing. An improvement would be to update the existing contact.- Any other code (401 invalid token, 403 no permission, 429 too many calls) stops the script with
raise_for_status(). lifecyclestageis the internal name of "Estado del ciclo de vida".
The token needs the crm.objects.contacts.write scope. It is best to create another private app (with its own token, TOKEN_CRM_ESCRITURA) instead of extending the read-only one: each integration with its minimum permissions, so that if the reporting script's token leaks, nobody can write to the CRM, and so that one integration can be revoked without affecting the other. In production, this code would live in the store or in func-hortalia-tareas, with the token in Key Vault.
Conclusion
In this exercise you have gone through the complete life of a SaaS application in a company: you have created a test account with data hosted in the EU, you have configured it (Europe/Madrid time zone, euros, Spanish formatting), you have created users and checked what permissions the plan offers, you have added a custom property, you have imported a fictional base of 14 customers while solving the typical errors of encoding, separators and duplicates, you have built Jordi's shops pipeline by renaming stages so as not to break integrations, you have logged a deal and an activity, you have created a sales dashboard, you have switched on and enforced two-step verification, you have queried the data through the API with a least-privilege token, you have exported the data to test the exit plan and you have deleted the account. All without a single server, and yet with plenty of work of your own: configuration, identities, data, integrations and the way out, exactly what the shared responsibility model said would still belong to the customer.
With this exercise we close module 4. You have learned what Software as a Service is and what its characteristics are, which providers offer it and how to evaluate them, what its use cases and antipatterns are, how to integrate it, protect it and govern it with a central identity, and how it is used from start to finish. Hortalia has now explored the three models separately: the legacy ERP on a virtual machine in IaaS, the hortalia-shop store on a PaaS platform with autoscaling, and email and the CRM in SaaS, with Microsoft 365 and HubSpot as prototypes. But so far every decision has been taken system by system, with prototypes and illustrative figures, and questions remain open: Google Workspace or Microsoft 365?, HubSpot, Dynamics 365 or Pipedrive?, could the ERP be a SaaS product?, did the store need PaaS or would Shopify have been enough?, how much does all of this cost over five years?, what do the regulations demand and what happens if one day you have to change provider? In module 5 we will compare the three models against criteria, costs, security and migration strategies so that Hortalia can take final decisions, starting with Criteria for Selecting the Right Model.
