Skip to main content

Overview

The Gigs API allows freelancers to create, update, and manage their service offerings. A gig represents a service that can be purchased by clients, with multiple pricing packages (basic, standard, premium).

Queries

doesOffersMultiplePackages

Check if a gig offers multiple package tiers. Input Parameters:
id
string
required
Gig ID (CUID)
Response: Returns boolean indicating if the gig offers multiple packages. Example:
const hasMultiple = await trpc.gig.doesOffersMultiplePackages.query({ 
  id: "clxxx..." 
});

getUserGigs

Retrieve all gigs belonging to a specific user. Input Parameters:
id
string
required
User ID
Response: Returns array of gig objects with:
id
string
Gig ID
title
string
Gig title
slug
string
URL-friendly slug
status
string
Status: draft, published, paused, or deleted
category
object
Category details (id, name, parentId)
packages
object
Package tiers: basic, standard, premium
attachaments
object
Media files: images, videos, documents
owner
object
Owner details (name, username)
Example:
const gigs = await trpc.gig.getUserGigs.query({ 
  id: "user_clxxx" 
});

Mutations

createDraft

Create a new draft gig for the authenticated user. Input Parameters: None (uses authenticated user from context) Response: Returns the created Gig object. Example:
const draft = await trpc.gig.createDraft.mutate();
console.log(draft.id); // Use this ID for subsequent updates

updateOverview

Update gig title, category, and tags. Input Parameters:
id
string
required
Gig ID to update
title
string
required
Gig title
category
string
required
Parent category ID
subCategory
string
required
Subcategory ID to connect
tags
array
required
Array of tag objects with id and text properties
Errors:
  • NOT_FOUND: Gig not found
Example:
await trpc.gig.updateOverview.mutate({
  id: "clxxx...",
  title: "I will build a modern React website",
  category: "design-creative",
  subCategory: "web-design",
  tags: [
    { id: "tag1", text: "react" },
    { id: "tag2", text: "nextjs" },
    { id: "tag3", text: "tailwind" }
  ]
});

createPackages

Create or update pricing packages for a gig. Supports basic (required), standard, and premium tiers. Input Parameters:
gigId
string
required
Gig ID
basic
object
required
Basic package details (always required)
basic.name
string
required
Package name (5-20 characters)
basic.description
string
required
Package description (5-100 characters)
basic.price
number
required
Price in MAD (minimum 10)
basic.delivery
number
required
Delivery time in days
basic.revisions
number
required
Number of revisions (minimum 1)
standard
object
Standard package (optional, same fields as basic)
premium
object
Premium package (optional, same fields as basic)
Response:
basic
object
Created/updated basic package
standard
object
Created/updated standard package (if provided)
premium
object
Created/updated premium package (if provided)
Example:
const packages = await trpc.gig.createPackages.mutate({
  gigId: "clxxx...",
  basic: {
    name: "Basic Website",
    description: "Simple 3-page website",
    price: 500,
    delivery: 7,
    revisions: 2
  },
  standard: {
    name: "Standard Website",
    description: "5-page website with contact form",
    price: 1000,
    delivery: 14,
    revisions: 4
  },
  premium: {
    name: "Premium Website",
    description: "10-page website with CMS integration",
    price: 2000,
    delivery: 21,
    revisions: 6
  }
});

udpateOffersMultiplePackages

Set whether the gig offers multiple package tiers. Input Parameters:
id
string
required
Gig ID
value
boolean
required
Whether to offer multiple packages
Example:
await trpc.gig.udpateOffersMultiplePackages.mutate({
  id: "clxxx...",
  value: true
});

updateDescriptionFaq

Update the gig description and FAQ section. Input Parameters:
id
string
required
Gig ID
description
object
required
EditorJS OutputData object with description content
faq
array
required
Array of FAQ objects
faq[].question
string
required
FAQ question
faq[].answer
string
required
FAQ answer
Response:
success
boolean
Operation success status
description
object
Updated description
faq
number
Number of FAQ items created
Errors:
  • UNAUTHORIZED: Gig not found or not owned by user
Example:
const result = await trpc.gig.updateDescriptionFaq.mutate({
  id: "clxxx...",
  description: {
    blocks: [
      {
        type: "paragraph",
        data: { text: "I will create a professional website..." }
      }
    ]
  },
  faq: [
    {
      question: "What do you need to get started?",
      answer: "I need your brand guidelines and content."
    },
    {
      question: "Do you provide hosting?",
      answer: "No, but I can recommend hosting providers."
    }
  ]
});

updateGallery

Update gig images, videos, and documents. Input Parameters:
id
string
required
Gig ID
images
array
required
Array of image URLs (at least one required)
videos
array
Array of video URLs
documents
array
Array of document URLs
Response:
success
boolean
Operation success status
images
array
Array of created attachment objects
Example:
const gallery = await trpc.gig.updateGallery.mutate({
  id: "clxxx...",
  images: [
    "https://khedma-market.s3.amazonaws.com/user-id/image1.jpg",
    "https://khedma-market.s3.amazonaws.com/user-id/image2.jpg"
  ]
});

publish

Publish a draft gig, making it visible to clients. Generates a unique slug. Input Parameters:
id
string
required
Gig ID to publish
Response:
id
string
Gig ID
slug
string
Generated URL slug
owner
object
Owner details (name, username)
Errors:
  • NOT_FOUND: Gig not found
  • UNPROCESSABLE_CONTENT: Title not set
Example:
const published = await trpc.gig.publish.mutate({ 
  id: "clxxx..." 
});

console.log(`View at: /${published.owner.username}/${published.slug}`);

delete

Delete a gig owned by the authenticated user. Input Parameters:
id
string
required
Gig ID to delete
Errors:
  • NOT_FOUND: Gig not found or not owned by user
Example:
await trpc.gig.delete.mutate({ 
  id: "clxxx..." 
});

Server-Side Functions

getGigById(id: string)

Fetch complete gig details by ID.

getGigDetails(username: string, slug: string)

Fetch full gig details for public display by owner username and slug.

getUserGigsByUsername(username: string)

Fetch all gigs for a user by username.

getGigPackages(id: string)

Fetch all package tiers for a gig.

getDescriptionFaq(id: string)

Fetch description and FAQ for a gig.

getGigGallery(id: string)

Fetch all media attachments for a gig.

Build docs developers (and LLMs) love