MortgageGuidelines API

Messages

Send the first message or continue an existing conversation.

Messages

POST /v1/messages handles the first turn and can create the conversation automatically. POST /v1/conversations/{conversationId}/messages continues an existing conversation.

First message

TypeScript fetch
const response = await fetch("https://api.mortgageguidelines.com/v1/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer mgapi_live_your_key_here",
    "Idempotency-Key": "first-turn-user-123-001",
  },
  body: JSON.stringify({
  "message": "What are FHA gift fund rules?",
  "user": {
    "external_user_id": "user_123",
    "email": "user@example.com",
    "name": "Test User"
  },
  "conversation": {
    "title": "FHA gift funds",
    "metadata": {
      "external_ticket_id": "ticket_789"
    }
  },
  "metadata": {
    "channel": "crm"
  }
}),
});

const data = await response.json();

Continue a conversation

TypeScript fetch
const response = await fetch("https://api.mortgageguidelines.com/v1/conversations/conv_3c2fd2bcf41f4f12/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": "mgapi_live_your_key_here",
    "Idempotency-Key": "follow-up-user-123-001",
  },
  body: JSON.stringify({
    message: "What documentation is required?",
    user: {
      external_user_id: "user_123",
    },
  }),
});

const data = await response.json();

Response shape

  • conversation_created is present only on POST /v1/messages
  • message_id always identifies the stored assistant message
  • metadata.tokens_used records the completion token count